diff options
Diffstat (limited to 'test/functional/repositories_mercurial_controller_test.rb')
-rw-r--r-- | test/functional/repositories_mercurial_controller_test.rb | 143 |
1 files changed, 71 insertions, 72 deletions
diff --git a/test/functional/repositories_mercurial_controller_test.rb b/test/functional/repositories_mercurial_controller_test.rb index 130adc695..cde27baa4 100644 --- a/test/functional/repositories_mercurial_controller_test.rb +++ b/test/functional/repositories_mercurial_controller_test.rb @@ -58,9 +58,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest @project.repository.destroy get :new, :project_id => 'subproject1', :repository_scm => 'Mercurial' assert_response :success - assert_template 'new' - assert_kind_of Repository::Mercurial, assigns(:repository) - assert assigns(:repository).new_record? + assert_select 'select[name=?]', 'repository_scm' do + assert_select 'option[value=?][selected=selected]', 'Mercurial' + end end def test_show_root @@ -70,14 +70,18 @@ class RepositoriesMercurialControllerTest < 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_equal 4, assigns(:entries).size - assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} - assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} - assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} - assert_not_nil assigns(:changesets) - assert assigns(:changesets).size > 0 + + assert_select 'table.entries tbody' do + assert_select 'tr', 4 + assert_select 'tr.dir td.filename a', :text => 'images' + assert_select 'tr.dir td.filename a', :text => 'sources' + assert_select 'tr.file td.filename a', :text => '.hgtags' + assert_select 'tr.file td.filename a', :text => 'README' + end + + assert_select 'table.changesets tbody' do + assert_select 'tr' + end end def test_show_directory @@ -87,15 +91,16 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest assert_equal NUM_REV, @repository.changesets.count get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param] assert_response :success - assert_template 'show' - assert_not_nil assigns(:entries) - assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) - entry = assigns(:entries).detect {|e| e.name == 'edit.png'} - assert_not_nil entry - assert_equal 'file', entry.kind - assert_equal 'images/edit.png', entry.path - assert_not_nil assigns(:changesets) - assert assigns(:changesets).size > 0 + + assert_select 'table.entries tbody' do + assert_select 'tr', 2 + assert_select 'tr.file td.filename a', :text => 'delete.png' + assert_select 'tr.file td.filename a', :text => 'edit.png' + end + + assert_select 'table.changesets tbody' do + assert_select 'tr' + end end def test_show_at_given_revision @@ -107,11 +112,15 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest get :show, :id => PRJ_ID, :path => repository_path_hash(['images'])[:param], :rev => r1 assert_response :success - assert_template 'show' - assert_not_nil assigns(:entries) - assert_equal ['delete.png'], assigns(:entries).collect(&:name) - assert_not_nil assigns(:changesets) - assert assigns(:changesets).size > 0 + + assert_select 'table.entries tbody' do + assert_select 'tr', 1 + assert_select 'tr.file td.filename a', :text => 'delete.png' + end + + assert_select 'table.changesets tbody' do + assert_select 'tr' + end end end @@ -125,15 +134,19 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest :path => repository_path_hash(['sql_escape', 'percent%dir'])[:param], :rev => r1 assert_response :success - assert_template 'show' - - assert_not_nil assigns(:entries) - assert_equal ['percent%file1.txt', 'percentfile1.txt'], - assigns(:entries).collect(&:name) - changesets = assigns(:changesets) - assert_not_nil changesets - assert assigns(:changesets).size > 0 - assert_equal %w(13 11 10 9), changesets.collect(&:revision) + + assert_select 'table.entries tbody' do + assert_select 'tr', 2 + assert_select 'tr.file td.filename a', :text => 'percent%file1.txt' + assert_select 'tr.file td.filename a', :text => 'percentfile1.txt' + end + + assert_select 'table.changesets tbody' do + assert_select 'tr td.id a', :text => /^13:/ + assert_select 'tr td.id a', :text => /^11:/ + assert_select 'tr td.id a', :text => /^10:/ + assert_select 'tr td.id a', :text => /^9:/ + end end end @@ -147,16 +160,22 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest :path => repository_path_hash(['latin-1-dir'])[:param], :rev => r1 assert_response :success - assert_template 'show' - - assert_not_nil assigns(:entries) - assert_equal ["make-latin-1-file.rb", - "test-#{@char_1}-1.txt", - "test-#{@char_1}-2.txt", - "test-#{@char_1}.txt"], assigns(:entries).collect(&:name) - changesets = assigns(:changesets) - assert_not_nil changesets - assert_equal %w(21 20 19 18 17), changesets.collect(&:revision) + + assert_select 'table.entries tbody' do + assert_select 'tr', 4 + assert_select 'tr.file td.filename a', :text => "make-latin-1-file.rb" + assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-1.txt" + assert_select 'tr.file td.filename a', :text => "test-#{@char_1}-2.txt" + assert_select 'tr.file td.filename a', :text => "test-#{@char_1}.txt" + end + + assert_select 'table.changesets tbody' do + assert_select 'tr td.id a', :text => /^21:/ + assert_select 'tr td.id a', :text => /^20:/ + assert_select 'tr td.id a', :text => /^19:/ + assert_select 'tr td.id a', :text => /^18:/ + assert_select 'tr td.id a', :text => /^17:/ + end end end @@ -186,11 +205,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest ].each do |bra| get :show, :id => PRJ_ID, :rev => bra assert_response :success - assert_template 'show' - assert_not_nil assigns(:entries) - assert assigns(:entries).size > 0 - assert_not_nil assigns(:changesets) - assert assigns(:changesets).size > 0 + + assert_select 'table.entries tbody tr' + assert_select 'table.changesets tbody tr' end end @@ -206,11 +223,9 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest ].each do |tag| get :show, :id => PRJ_ID, :rev => tag assert_response :success - assert_template 'show' - assert_not_nil assigns(:entries) - assert assigns(:entries).size > 0 - assert_not_nil assigns(:changesets) - assert assigns(:changesets).size > 0 + + assert_select 'table.entries tbody tr' + assert_select 'table.changesets tbody tr' end end @@ -218,7 +233,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest get :changes, :id => PRJ_ID, :path => repository_path_hash(['images', 'edit.png'])[:param] assert_response :success - assert_template 'changes' assert_select 'h2', :text => /edit.png/ end @@ -226,7 +240,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest get :entry, :id => PRJ_ID, :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success - assert_template 'entry' # Line 10 assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/ end @@ -237,7 +250,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], :rev => r1 assert_response :success - assert_template 'entry' assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/ end end @@ -249,7 +261,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], :rev => r1 assert_response :success - assert_template 'entry' assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ end end @@ -272,9 +283,8 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest get :entry, :id => PRJ_ID, :path => repository_path_hash(['sources'])[:param] assert_response :success - assert_template 'show' - assert_not_nil assigns(:entry) - assert_equal 'sources', assigns(:entry).name + assert_select 'h2 a', :text => 'sources' + assert_select 'table.entries tbody' end def test_diff @@ -287,7 +297,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest ['inline', 'sbs'].each do |dt| get :diff, :id => PRJ_ID, :rev => r1, :type => dt assert_response :success - assert_template 'diff' if @diff_c_support # Line 22 removed assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ @@ -311,9 +320,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest :rev_to => r2, :type => dt assert_response :success - assert_template 'diff' - diff = assigns(:diff) - assert_not_nil diff assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/ end end @@ -326,7 +332,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest ['inline', 'sbs'].each do |dt| get :diff, :id => PRJ_ID, :rev => r1, :type => dt assert_response :success - assert_template 'diff' assert_select 'table' do assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{@char_1}-2.txt/ assert_select 'tbody td.diff_in', :text => /It is written in Python/ @@ -339,14 +344,12 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest def test_diff_should_show_modified_filenames get :diff, :id => PRJ_ID, :rev => '400bb8672109', :type => 'inline' assert_response :success - assert_template 'diff' assert_select 'th.filename', :text => 'sources/watchers_controller.rb' end def test_diff_should_show_deleted_filenames get :diff, :id => PRJ_ID, :rev => 'b3a615152df8', :type => 'inline' assert_response :success - assert_template 'diff' assert_select 'th.filename', :text => 'sources/welcome_controller.rb' end @@ -354,7 +357,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest get :annotate, :id => PRJ_ID, :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success - assert_template 'annotate' # Line 22, revision 4:def6d2f1254a assert_select 'tr' do @@ -385,7 +387,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest get :annotate, :id => PRJ_ID, :rev => r1, :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success - assert_template 'annotate' assert_select 'h2', :text => /@ 2:400bb8672109/ end end @@ -396,7 +397,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}-2.txt"])[:param], :rev => r1 assert_response :success - assert_template 'annotate' assert_select "th.line-num", :text => '1' do assert_select "+ td.revision" do assert_select "a", :text => '20:709858aafd1b' @@ -429,7 +429,6 @@ class RepositoriesMercurialControllerTest < Redmine::ControllerTest with_settings :default_language => "en" do get :revision, :id => PRJ_ID, :rev => r assert_response :success - assert_template 'revision' assert_select 'title', :text => 'Revision 1:9d5b5b004199 - Added 2 files and modified one. - eCookbook Subproject 1 - Redmine' end |