kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
310 lines
11 KiB
310 lines
11 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
17 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
17 years ago
|
require 'repositories_controller'
|
||
|
|
||
11 years ago
|
describe RepositoriesController, 'Subversion', type: :controller do
|
||
|
render_views
|
||
|
|
||
12 years ago
|
fixtures :all
|
||
17 years ago
|
|
||
14 years ago
|
PRJ_ID = 3
|
||
|
|
||
11 years ago
|
before do
|
||
10 years ago
|
skip 'Subversion test repository NOT FOUND. Skipping functional tests !!!' unless repository_configured?('subversion')
|
||
|
|
||
17 years ago
|
Setting.default_language = 'en'
|
||
17 years ago
|
User.current = nil
|
||
14 years ago
|
|
||
|
@project = Project.find(PRJ_ID)
|
||
10 years ago
|
@repository = Repository::Subversion.create(project: @project,
|
||
9 years ago
|
scm_type: 'local',
|
||
10 years ago
|
url: self.class.subversion_repository_url)
|
||
12 years ago
|
|
||
|
# #reload is broken for repositories because it defines
|
||
|
# `has_many :changes` which conflicts with AR's #changes method
|
||
|
# here we implement #reload differently for that single repository instance
|
||
|
def @repository.reload
|
||
|
ActiveRecord::Base.connection.clear_query_cache
|
||
10 years ago
|
self.class.find(id)
|
||
12 years ago
|
end
|
||
|
|
||
14 years ago
|
assert @repository
|
||
17 years ago
|
end
|
||
|
|
||
10 years ago
|
it 'should show' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :show, project_id: PRJ_ID
|
||
|
assert_response :success
|
||
|
assert_template 'show'
|
||
9 years ago
|
refute_nil assigns(:entries)
|
||
|
refute_nil assigns(:changesets)
|
||
10 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should browse root' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :show, project_id: PRJ_ID
|
||
|
assert_response :success
|
||
|
assert_template 'show'
|
||
9 years ago
|
refute_nil assigns(:entries)
|
||
10 years ago
|
entry = assigns(:entries).detect { |e| e.name == 'subversion_test' }
|
||
|
assert_equal 'dir', entry.kind
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should browse directory' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :show, project_id: PRJ_ID, path: 'subversion_test'
|
||
|
assert_response :success
|
||
|
assert_template 'show'
|
||
9 years ago
|
refute_nil assigns(:entries)
|
||
10 years ago
|
assert_equal ['[folder_with_brackets]', 'folder', '.project', 'helloworld.c', 'textfile.txt'], assigns(:entries).map(&:name)
|
||
10 years ago
|
entry = assigns(:entries).detect { |e| e.name == 'helloworld.c' }
|
||
|
assert_equal 'file', entry.kind
|
||
|
assert_equal 'subversion_test/helloworld.c', entry.path
|
||
|
assert_tag :a, content: 'helloworld.c', attributes: { class: /text\-x\-c/ }
|
||
|
end
|
||
17 years ago
|
|
||
10 years ago
|
it 'should browse at given revision' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :show, project_id: PRJ_ID, path: 'subversion_test', rev: 4
|
||
|
assert_response :success
|
||
|
assert_template 'show'
|
||
9 years ago
|
refute_nil assigns(:entries)
|
||
10 years ago
|
assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], assigns(:entries).map(&:name)
|
||
10 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should file changes' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :changes, project_id: PRJ_ID, path: 'subversion_test/folder/helloworld.rb'
|
||
|
assert_response :success
|
||
|
assert_template 'changes'
|
||
|
|
||
|
changesets = assigns(:changesets)
|
||
9 years ago
|
refute_nil changesets
|
||
10 years ago
|
assert_equal %w(6 3 2), changesets.map(&:revision)
|
||
10 years ago
|
|
||
|
# svn properties displayed with svn >= 1.5 only
|
||
10 years ago
|
if @repository.scm.client_version_above?([1, 5, 0])
|
||
9 years ago
|
refute_nil assigns(:properties)
|
||
10 years ago
|
assert_equal 'native', assigns(:properties)['svn:eol-style']
|
||
|
assert_tag :ul,
|
||
|
child: { tag: 'li',
|
||
|
child: { tag: 'b', content: 'svn:eol-style' },
|
||
|
child: { tag: 'span', content: 'native' } }
|
||
17 years ago
|
end
|
||
10 years ago
|
end
|
||
15 years ago
|
|
||
10 years ago
|
it 'should directory changes' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :changes, project_id: PRJ_ID, path: 'subversion_test/folder'
|
||
|
assert_response :success
|
||
|
assert_template 'changes'
|
||
14 years ago
|
|
||
10 years ago
|
changesets = assigns(:changesets)
|
||
9 years ago
|
refute_nil changesets
|
||
10 years ago
|
assert_equal %w(10 9 7 6 5 2), changesets.map(&:revision)
|
||
10 years ago
|
end
|
||
|
|
||
|
it 'should entry' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.c'
|
||
|
assert_response :success
|
||
|
assert_template 'entry'
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should entry should send if too big' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
# no files in the test repo is larger than 1KB...
|
||
|
with_settings file_max_size_displayed: 0 do
|
||
10 years ago
|
get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.c'
|
||
17 years ago
|
assert_response :success
|
||
10 years ago
|
assert_template nil
|
||
10 years ago
|
assert_equal 'attachment; filename="helloworld.c"', response.headers['Content-Disposition']
|
||
17 years ago
|
end
|
||
10 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should entry at given revision' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.rb', rev: 2
|
||
|
assert_response :success
|
||
|
assert_template 'entry'
|
||
|
# this line was removed in r3 and file was moved in r6
|
||
|
assert_tag tag: 'td', attributes: { class: /line-code/ },
|
||
|
content: /Here's the code/
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should entry not found' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :entry, project_id: PRJ_ID, path: 'subversion_test/zzz.c'
|
||
|
assert_tag tag: 'div', attributes: { id: /errorExplanation/ },
|
||
|
content: /The entry or revision was not found in the repository/
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should entry download' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :entry, project_id: PRJ_ID, path: 'subversion_test/helloworld.c', format: 'raw'
|
||
|
assert_response :success
|
||
|
assert_template nil
|
||
10 years ago
|
assert_equal 'attachment; filename="helloworld.c"', response.headers['Content-Disposition']
|
||
10 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should directory entry' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :entry, project_id: PRJ_ID, path: 'subversion_test/folder'
|
||
|
assert_response :success
|
||
|
assert_template 'show'
|
||
9 years ago
|
refute_nil assigns(:entry)
|
||
10 years ago
|
assert_equal 'folder', assigns(:entry).name
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
# TODO: this test needs fixtures.
|
||
|
it 'should revision' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :revision, project_id: 1, rev: 2
|
||
|
assert_response :success
|
||
|
assert_template 'revision'
|
||
|
assert_tag tag: 'ul',
|
||
|
child: { tag: 'li',
|
||
|
# link to the entry at rev 2
|
||
|
child: { tag: 'a',
|
||
|
attributes: { href: '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo' },
|
||
|
content: 'repo',
|
||
|
# link to partial diff
|
||
|
sibling: { tag: 'a',
|
||
|
attributes: { href: '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should invalid revision' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :revision, project_id: PRJ_ID, rev: 'something_weird'
|
||
|
assert_response 404
|
||
|
assert_error_tag content: /was not found/
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should invalid revision diff' do
|
||
|
get :diff, project_id: PRJ_ID, rev: '1', rev_to: 'something_weird'
|
||
|
assert_response 404
|
||
|
assert_error_tag content: /was not found/
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should empty revision' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
['', ' ', nil].each do |r|
|
||
|
get :revision, project_id: PRJ_ID, rev: r
|
||
14 years ago
|
assert_response 404
|
||
10 years ago
|
assert_error_tag content: /was not found/
|
||
14 years ago
|
end
|
||
10 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
# TODO: this test needs fixtures.
|
||
|
it 'should revision with repository pointing to a subdirectory' do
|
||
|
r = Project.find(1).repository
|
||
|
# Changes repository url to a subdirectory
|
||
9 years ago
|
r.update_attribute :url, (r.url + '/subversion_test/folder/')
|
||
10 years ago
|
|
||
|
get :revision, project_id: 1, rev: 2
|
||
|
assert_response :success
|
||
|
assert_template 'revision'
|
||
|
assert_tag tag: 'ul',
|
||
|
child: { tag: 'li',
|
||
|
# link to the entry at rev 2
|
||
|
child: { tag: 'a',
|
||
9 years ago
|
attributes: { href: '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo' },
|
||
10 years ago
|
content: 'repo',
|
||
|
# link to partial diff
|
||
|
sibling: { tag: 'a',
|
||
9 years ago
|
attributes: { href: '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
|
||
10 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should revision diff' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :diff, project_id: PRJ_ID, rev: 3
|
||
|
assert_response :success
|
||
|
assert_template 'diff'
|
||
14 years ago
|
|
||
10 years ago
|
assert_tag tag: 'h2', content: /3/
|
||
|
end
|
||
15 years ago
|
|
||
10 years ago
|
it 'should directory diff' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :diff, project_id: PRJ_ID, rev: 6, rev_to: 2, path: 'subversion_test/folder'
|
||
|
assert_response :success
|
||
|
assert_template 'diff'
|
||
14 years ago
|
|
||
10 years ago
|
diff = assigns(:diff)
|
||
9 years ago
|
refute_nil diff
|
||
10 years ago
|
# 2 files modified
|
||
|
assert_equal 2, Redmine::UnifiedDiff.new(diff).size
|
||
14 years ago
|
|
||
10 years ago
|
assert_tag tag: 'h2', content: /2:6/
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should annotate' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :annotate, project_id: PRJ_ID, path: 'subversion_test/helloworld.c'
|
||
|
assert_response :success
|
||
|
assert_template 'annotate'
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'should annotate at given revision' do
|
||
|
@repository.fetch_changesets
|
||
|
@repository.reload
|
||
|
get :annotate, project_id: PRJ_ID, rev: 8, path: 'subversion_test/helloworld.c'
|
||
|
assert_response :success
|
||
|
assert_template 'annotate'
|
||
9 years ago
|
assert_tag tag: 'div',
|
||
|
attributes: { class: 'repository-breadcrumbs' },
|
||
|
content: /at 8/
|
||
17 years ago
|
end
|
||
|
end
|