Removes calls to #assert_template and #assigns in functional tests.

git-svn-id: http://svn.redmine.org/redmine/trunk@15725 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2016-07-21 17:48:05 +00:00
parent 29ddc82a11
commit 00f709ad4d
8 changed files with 272 additions and 309 deletions

View File

@@ -43,9 +43,9 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
@project.repository.destroy
get :new, :project_id => 'subproject1', :repository_scm => 'Subversion'
assert_response :success
assert_template 'new'
assert_kind_of Repository::Subversion, assigns(:repository)
assert assigns(:repository).new_record?
assert_select 'select[name=?]', 'repository_scm' do
assert_select 'option[value=?][selected=selected]', 'Subversion'
end
end
def test_show
@@ -55,14 +55,17 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
assert_equal NUM_REV, @repository.changesets.count
get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
assert_not_nil assigns(:changesets)
entry = assigns(:entries).detect {|e| e.name == 'subversion_test'}
assert_not_nil entry
assert_equal 'dir', entry.kind
assert_select 'tr.dir a[href="/projects/subproject1/repository/show/subversion_test"]'
assert_select 'table.entries tbody' do
assert_select 'tr', 1
assert_select 'tr.dir td.filename a', :text => 'subversion_test'
assert_select 'tr.dir td.filename a[href=?]', '/projects/subproject1/repository/show/subversion_test'
end
assert_select 'table.changesets tbody' do
assert_select 'tr', 10
assert_select 'tr td.id a', :text => '11'
end
assert_select 'input[name=rev]'
assert_select 'a', :text => 'Statistics'
@@ -77,7 +80,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :show, :id => PRJ_ID, :repository_id => 'svn'
assert_response :success
assert_template 'show'
assert_select 'tr.dir a[href="/projects/subproject1/repository/svn/show/subversion_test"]'
# Repository menu should link to the main repo
assert_select '#main-menu a[href="/projects/subproject1/repository"]'
@@ -90,16 +93,16 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
assert_equal NUM_REV, @repository.changesets.count
get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param]
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
assert_equal [
'[folder_with_brackets]', 'folder', '.project',
'helloworld.c', 'textfile.txt'
],
assigns(:entries).collect(&:name)
entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'}
assert_equal 'file', entry.kind
assert_equal 'subversion_test/helloworld.c', entry.path
assert_select 'table.entries tbody' do
assert_select 'tr', 5
assert_select 'tr.dir td.filename a', :text => '[folder_with_brackets]'
assert_select 'tr.dir td.filename a', :text => 'folder'
assert_select 'tr.file td.filename a', :text => '.project'
assert_select 'tr.file td.filename a', :text => 'helloworld.c'
assert_select 'tr.file td.filename a', :text => 'textfile.txt'
end
assert_select 'a.text-x-c', :text => 'helloworld.c'
end
@@ -111,10 +114,15 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param],
:rev => 4
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'],
assigns(:entries).collect(&:name)
assert_select 'table.entries tbody' do
assert_select 'tr', 5
assert_select 'tr.dir td.filename a', :text => 'folder'
assert_select 'tr.file td.filename a', :text => '.project'
assert_select 'tr.file td.filename a', :text => 'helloworld.c'
assert_select 'tr.file td.filename a', :text => 'helloworld.rb'
assert_select 'tr.file td.filename a', :text => 'textfile.txt'
end
end
def test_file_changes
@@ -125,16 +133,16 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :changes, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param]
assert_response :success
assert_template 'changes'
changesets = assigns(:changesets)
assert_not_nil changesets
assert_equal %w(6 3 2), changesets.collect(&:revision)
assert_select 'table.changesets tbody' do
assert_select 'tr', 3
assert_select 'tr td.id a', :text => '6'
assert_select 'tr td.id a', :text => '3'
assert_select 'tr td.id a', :text => '2'
end
# svn properties displayed with svn >= 1.5 only
if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0])
assert_not_nil assigns(:properties)
assert_equal 'native', assigns(:properties)['svn:eol-style']
assert_select 'ul li' do
assert_select 'b', :text => 'svn:eol-style'
assert_select 'span', :text => 'native'
@@ -150,11 +158,16 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :changes, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
assert_response :success
assert_template 'changes'
changesets = assigns(:changesets)
assert_not_nil changesets
assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
assert_select 'table.changesets tbody' do
assert_select 'tr', 6
assert_select 'tr td.id a', :text => '10'
assert_select 'tr td.id a', :text => '9'
assert_select 'tr td.id a', :text => '7'
assert_select 'tr td.id a', :text => '6'
assert_select 'tr td.id a', :text => '5'
assert_select 'tr td.id a', :text => '2'
end
end
def test_entry
@@ -165,7 +178,8 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
assert_response :success
assert_template 'entry'
assert_select 'h2 a', :text => 'subversion_test'
assert_select 'h2 a', :text => 'helloworld.c'
end
def test_entry_should_show_other_if_too_big
@@ -187,7 +201,7 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'folder', 'subfolder', 'rubylogo.gif'])[:param]
assert_response :success
assert_template 'entry'
assert_select 'img[src=?]', '/projects/subproject1/repository/raw/subversion_test/folder/subfolder/rubylogo.gif'
end
def test_entry_at_given_revision
@@ -199,7 +213,6 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
:path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param],
:rev => 2
assert_response :success
assert_template 'entry'
# this line was removed in r3 and file was moved in r6
assert_select 'td.line-code', :text => /Here's the code/
end
@@ -233,16 +246,14 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'folder'])[:param]
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entry)
assert_equal 'folder', assigns(:entry).name
assert_select 'h2 a', :text => 'subversion_test'
assert_select 'h2 a', :text => 'folder'
end
# TODO: this test needs fixtures.
def test_revision
get :revision, :id => 1, :rev => 2
assert_response :success
assert_template 'revision'
assert_select 'ul' do
assert_select 'li' do
@@ -290,7 +301,6 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :revision, :id => 1, :rev => 2
assert_response :success
assert_template 'revision'
assert_select 'ul' do
assert_select 'li' do
@@ -310,7 +320,6 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
['inline', 'sbs'].each do |dt|
get :diff, :id => PRJ_ID, :rev => 3, :type => dt
assert_response :success
assert_template 'diff'
assert_select 'h2', :text => /Revision 3/
assert_select 'th.filename', :text => 'subversion_test/textfile.txt'
end
@@ -338,13 +347,12 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
:path => repository_path_hash(['subversion_test', 'folder'])[:param],
:type => dt
assert_response :success
assert_template 'diff'
diff = assigns(:diff)
assert_not_nil diff
# 2 files modified
assert_equal 2, Redmine::UnifiedDiff.new(diff).size
assert_select 'h2', :text => /2:6/
# 2 files modified
assert_select 'table.filecontent', 2
assert_select 'table.filecontent thead th.filename', :text => 'greeter.rb'
assert_select 'table.filecontent thead th.filename', :text => 'helloworld.rb'
end
end
@@ -356,7 +364,6 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :annotate, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
assert_response :success
assert_template 'annotate'
assert_select 'tr' do
assert_select 'th.line-num', :text => '1'
@@ -380,7 +387,6 @@ class RepositoriesSubversionControllerTest < Redmine::ControllerTest
get :annotate, :id => PRJ_ID, :rev => 8,
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
assert_response :success
assert_template 'annotate'
assert_select 'h2', :text => /@ 8/
end