diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-22 09:38:21 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-11-22 09:38:21 +0000 |
commit | f3e573b5f891c71f9395562a3f8747ecec801091 (patch) | |
tree | 7987fd3efa8ae985b532a03e7e0f529fa997258d /test/functional | |
parent | 3602cd637c9ece4e0caa42c335acb7dce719a20e (diff) | |
download | redmine-f3e573b5f891c71f9395562a3f8747ecec801091.tar.gz redmine-f3e573b5f891c71f9395562a3f8747ecec801091.zip |
Replaced remaining #assert_tag with #assert_select.
git-svn-id: http://svn.redmine.org/redmine/trunk@13624 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
31 files changed, 273 insertions, 491 deletions
diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 114684b30..4850886b9 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -166,7 +166,7 @@ class AccountControllerTest < ActionController::TestCase post :login, :username => 'jsmith', :password => 'jsmith' assert_response 500 - assert_error_tag :content => /Something wrong/ + assert_select_error /Something wrong/ end def test_login_should_reset_session diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index 664814023..5185d2c0e 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -74,7 +74,7 @@ class AuthSourcesControllerTest < ActionController::TestCase assert_response :success assert_template 'new' end - assert_error_tag :content => /host #{ESCAPED_CANT} be blank/i + assert_select_error /host #{ESCAPED_CANT} be blank/i end def test_edit @@ -118,7 +118,7 @@ class AuthSourcesControllerTest < ActionController::TestCase :port => '389', :attr_login => 'uid'} assert_response :success assert_template 'edit' - assert_error_tag :content => /host #{ESCAPED_CANT} be blank/i + assert_select_error /host #{ESCAPED_CANT} be blank/i end def test_destroy diff --git a/test/functional/issue_statuses_controller_test.rb b/test/functional/issue_statuses_controller_test.rb index 2c5164ff7..a35244759 100644 --- a/test/functional/issue_statuses_controller_test.rb +++ b/test/functional/issue_statuses_controller_test.rb @@ -62,7 +62,7 @@ class IssueStatusesControllerTest < ActionController::TestCase post :create, :issue_status => {:name => ''} assert_response :success assert_template 'new' - assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i + assert_select_error /name #{ESCAPED_CANT} be blank/i end def test_edit @@ -82,7 +82,7 @@ class IssueStatusesControllerTest < ActionController::TestCase put :update, :id => '3', :issue_status => {:name => ''} assert_response :success assert_template 'edit' - assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i + assert_select_error /name #{ESCAPED_CANT} be blank/i end def test_destroy diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 6680557bc..1c3702c67 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -1729,7 +1729,7 @@ class IssuesControllerTest < ActionController::TestCase get :new, :project_id => 1 assert_response 500 - assert_error_tag :content => /No default issue/ + assert_select_error /No default issue/ end def test_get_new_with_no_tracker_should_display_an_error @@ -1738,7 +1738,7 @@ class IssuesControllerTest < ActionController::TestCase get :new, :project_id => 1 assert_response 500 - assert_error_tag :content => /No tracker/ + assert_select_error /No tracker/ end def test_update_form_for_new_issue @@ -1977,7 +1977,7 @@ class IssuesControllerTest < ActionController::TestCase assert_template 'new' issue = assigns(:issue) assert_not_nil issue - assert_error_tag :content => /Database #{ESCAPED_CANT} be blank/ + assert_select_error /Database #{ESCAPED_CANT} be blank/ end def test_create_should_validate_required_fields @@ -2001,8 +2001,8 @@ class IssuesControllerTest < ActionController::TestCase assert_template 'new' end - assert_error_tag :content => /Due date #{ESCAPED_CANT} be blank/i - assert_error_tag :content => /Bar #{ESCAPED_CANT} be blank/i + assert_select_error /Due date #{ESCAPED_CANT} be blank/i + assert_select_error /Bar #{ESCAPED_CANT} be blank/i end def test_create_should_ignore_readonly_fields @@ -2096,7 +2096,7 @@ class IssuesControllerTest < ActionController::TestCase assert_response :success assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', '4' - assert_error_tag :content => /Parent task is invalid/i + assert_select_error /Parent task is invalid/i end end @@ -2111,7 +2111,7 @@ class IssuesControllerTest < ActionController::TestCase assert_response :success assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', '01ABC' - assert_error_tag :content => /Parent task is invalid/i + assert_select_error /Parent task is invalid/i end end @@ -3219,7 +3219,7 @@ class IssuesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_error_tag :descendant => {:content => /Activity #{ESCAPED_CANT} be blank/} + assert_select_error /Activity #{ESCAPED_CANT} be blank/ assert_select 'textarea[name=?]', 'issue[notes]', :text => notes assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2z' end @@ -3237,8 +3237,8 @@ class IssuesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_error_tag :descendant => {:content => /Activity #{ESCAPED_CANT} be blank/} - assert_error_tag :descendant => {:content => /Hours #{ESCAPED_CANT} be blank/} + assert_select_error /Activity #{ESCAPED_CANT} be blank/ + assert_select_error /Hours #{ESCAPED_CANT} be blank/ assert_select 'textarea[name=?]', 'issue[notes]', :text => notes assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'this is my comment' end diff --git a/test/functional/issues_controller_transaction_test.rb b/test/functional/issues_controller_transaction_test.rb index 5f2b3dfeb..c9fc9d2a7 100644 --- a/test/functional/issues_controller_transaction_test.rb +++ b/test/functional/issues_controller_transaction_test.rb @@ -103,8 +103,8 @@ class IssuesControllerTransactionTest < ActionController::TestCase assert_response :success assert_template 'edit' attachment = Attachment.order('id DESC').first - assert_tag 'input', :attributes => {:name => 'attachments[p0][token]', :value => attachment.token} - assert_tag 'input', :attributes => {:name => 'attachments[p0][filename]', :value => 'testfile.txt'} + assert_select 'input[name=?][value=?]', 'attachments[p0][token]', attachment.token + assert_select 'input[name=?][value=?]', 'attachments[p0][filename]', 'testfile.txt' end def test_update_stale_issue_without_notes_should_not_show_add_notes_option @@ -118,10 +118,10 @@ class IssuesControllerTransactionTest < ActionController::TestCase :lock_version => (issue.lock_version - 1) } - assert_tag 'div', :attributes => {:class => 'conflict'} - assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'overwrite'} - assert_no_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'add_notes'} - assert_tag 'input', :attributes => {:name => 'conflict_resolution', :value => 'cancel'} + assert_select 'div.conflict' + assert_select 'input[name=conflict_resolution][value=overwrite]' + assert_select 'input[name=conflict_resolution][value=add_notes]', 0 + assert_select 'input[name=conflict_resolution][value=cancel]' end def test_update_stale_issue_should_show_conflicting_journals @@ -138,8 +138,8 @@ class IssuesControllerTransactionTest < ActionController::TestCase assert_not_nil assigns(:conflict_journals) assert_equal 1, assigns(:conflict_journals).size assert_equal 2, assigns(:conflict_journals).first.id - assert_tag 'div', :attributes => {:class => 'conflict'}, - :descendant => {:content => /Some notes with Redmine links/} + + assert_select 'div.conflict', :text => /Some notes with Redmine links/ end def test_update_stale_issue_without_previous_journal_should_show_all_journals @@ -155,10 +155,8 @@ class IssuesControllerTransactionTest < ActionController::TestCase assert_not_nil assigns(:conflict_journals) assert_equal 2, assigns(:conflict_journals).size - assert_tag 'div', :attributes => {:class => 'conflict'}, - :descendant => {:content => /Some notes with Redmine links/} - assert_tag 'div', :attributes => {:class => 'conflict'}, - :descendant => {:content => /Journal notes/} + assert_select 'div.conflict', :text => /Some notes with Redmine links/ + assert_select 'div.conflict', :text => /Journal notes/ end def test_update_stale_issue_should_show_private_journals_with_permission_only @@ -256,7 +254,7 @@ class IssuesControllerTransactionTest < ActionController::TestCase get :index assert_response 500 - assert_tag 'p', :content => /An error occurred/ + assert_select 'p', :text => /An error occurred/ assert_nil session[:query] assert_nil session[:issues_index_sort] end diff --git a/test/functional/messages_controller_test.rb b/test/functional/messages_controller_test.rb index 8b15d517a..8aba1fb0e 100644 --- a/test/functional/messages_controller_test.rb +++ b/test/functional/messages_controller_test.rb @@ -39,9 +39,9 @@ class MessagesControllerTest < ActionController::TestCase assert_response :success # tags required by MessagesController#quote - assert_tag 'input', :attributes => {:id => 'message_subject'} - assert_tag 'textarea', :attributes => {:id => 'message_content'} - assert_tag 'div', :attributes => {:id => 'reply'} + assert_select 'input#message_subject' + assert_select 'textarea#message_content' + assert_select 'div#reply' end def test_show_with_pagination @@ -68,8 +68,7 @@ class MessagesControllerTest < ActionController::TestCase get :show, :board_id => 1, :id => 1 assert_response :success assert_template 'show' - assert_tag :div, :attributes => { :id => 'reply' }, - :descendant => { :tag => 'textarea', :attributes => { :id => 'message_content' } } + assert_select 'div#reply textarea#message_content' end def test_show_message_not_found diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index ea0184b2d..db4a92c2d 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -68,7 +68,7 @@ class MyControllerTest < ActionController::TestCase assert_template 'account' assert_equal User.find(2), assigns(:user) - assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} + assert_select 'input[name=?]', 'user[custom_field_values][4]' end def test_my_account_should_not_show_non_editable_custom_fields @@ -79,7 +79,7 @@ class MyControllerTest < ActionController::TestCase assert_template 'account' assert_equal User.find(2), assigns(:user) - assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'} + assert_select 'input[name=?]', 'user[custom_field_values][4]', 0 end def test_my_account_should_show_language_select @@ -167,7 +167,7 @@ class MyControllerTest < ActionController::TestCase :new_password_confirmation => 'secret1234' assert_response :success assert_template 'password' - assert_error_tag :content => /Password doesn.*t match confirmation/ + assert_select_error /Password doesn.*t match confirmation/ # wrong password post :password, :password => 'wrongpassword', diff --git a/test/functional/news_controller_test.rb b/test/functional/news_controller_test.rb index 7d342605f..8dfa9cf42 100644 --- a/test/functional/news_controller_test.rb +++ b/test/functional/news_controller_test.rb @@ -50,7 +50,7 @@ class NewsControllerTest < ActionController::TestCase get :show, :id => 1 assert_response :success assert_template 'show' - assert_tag :tag => 'h2', :content => /eCookbook first release/ + assert_select 'h2', :text => /eCookbook first release/ end def test_show_should_show_attachments @@ -60,7 +60,7 @@ class NewsControllerTest < ActionController::TestCase get :show, :id => 1 assert_response :success - assert_tag 'a', :content => attachment.filename + assert_select 'a', :text => attachment.filename end def test_show_with_comments_in_reverse_order @@ -129,7 +129,7 @@ class NewsControllerTest < ActionController::TestCase assert_template 'new' assert_not_nil assigns(:news) assert assigns(:news).new_record? - assert_error_tag :content => /title #{ESCAPED_CANT} be blank/i + assert_select_error /title #{ESCAPED_CANT} be blank/i end def test_get_edit @@ -166,7 +166,7 @@ class NewsControllerTest < ActionController::TestCase put :update, :id => 1, :news => { :description => '' } assert_response :success assert_template 'edit' - assert_error_tag :content => /description #{ESCAPED_CANT} be blank/i + assert_select_error /description #{ESCAPED_CANT} be blank/i end def test_destroy diff --git a/test/functional/previews_controller_test.rb b/test/functional/previews_controller_test.rb index abbbd7afa..610f0488f 100644 --- a/test/functional/previews_controller_test.rb +++ b/test/functional/previews_controller_test.rb @@ -51,7 +51,7 @@ class PreviewsControllerTest < ActionController::TestCase assert_response :success assert_template 'previews/issue' assert_not_nil assigns(:notes) - assert_tag :p, :content => 'Foo' + assert_select 'p', :text => 'Foo' end def test_preview_issue_notes_should_support_links_to_existing_attachments @@ -77,8 +77,7 @@ class PreviewsControllerTest < ActionController::TestCase :summary => ''} assert_response :success assert_template 'common/_preview' - assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, - :content => /News description/ + assert_select 'fieldset.preview', :text => /News description/ end def test_existing_new_news @@ -91,7 +90,6 @@ class PreviewsControllerTest < ActionController::TestCase assert_equal News.find(2), assigns(:previewed) assert_not_nil assigns(:attachments) - assert_tag :tag => 'fieldset', :attributes => { :class => 'preview' }, - :content => /News description/ + assert_select 'fieldset.preview', :text => /News description/ end end diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 60bc580d3..726148dad 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -422,7 +422,7 @@ class ProjectsControllerTest < ActionController::TestCase post :update, :id => 1, :project => {:name => ''} assert_response :success assert_template 'settings' - assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i + assert_select_error /name #{ESCAPED_CANT} be blank/i end def test_update_should_be_denied_for_member_on_closed_project diff --git a/test/functional/queries_controller_test.rb b/test/functional/queries_controller_test.rb index 337478de6..faf539b6d 100644 --- a/test/functional/queries_controller_test.rb +++ b/test/functional/queries_controller_test.rb @@ -36,10 +36,7 @@ class QueriesControllerTest < ActionController::TestCase assert_response :success assert_template 'new' assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]' - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'query_is_for_all', - :checked => nil, - :disabled => nil } + assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])' assert_select 'select[name=?]', 'c[]' do assert_select 'option[value=tracker]' assert_select 'option[value=subject]' @@ -52,10 +49,7 @@ class QueriesControllerTest < ActionController::TestCase assert_response :success assert_template 'new' assert_select 'input[name=?]', 'query[visibility]', 0 - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'query_is_for_all', - :checked => 'checked', - :disabled => nil } + assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])' end def test_new_on_invalid_project @@ -198,10 +192,7 @@ class QueriesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'query_is_for_all', - :checked => 'checked', - :disabled => 'disabled' } + assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked][disabled=disabled]' end def test_edit_global_private_query @@ -210,10 +201,7 @@ class QueriesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' assert_select 'input[name=?]', 'query[visibility]', 0 - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'query_is_for_all', - :checked => 'checked', - :disabled => 'disabled' } + assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked][disabled=disabled]' end def test_edit_project_private_query @@ -222,10 +210,7 @@ class QueriesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' assert_select 'input[name=?]', 'query[visibility]', 0 - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'query_is_for_all', - :checked => nil, - :disabled => nil } + assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])' end def test_edit_project_public_query @@ -234,10 +219,7 @@ class QueriesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'query_is_for_all', - :checked => nil, - :disabled => 'disabled' } + assert_select 'input[name=query_is_for_all][type=checkbox][disabled=disabled]:not([checked])' end def test_edit_sort_criteria @@ -245,12 +227,10 @@ class QueriesControllerTest < ActionController::TestCase get :edit, :id => 5 assert_response :success assert_template 'edit' - assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' }, - :child => { :tag => 'option', :attributes => { :value => 'priority', - :selected => 'selected' } } - assert_tag :tag => 'select', :attributes => { :name => 'query[sort_criteria][0][]' }, - :child => { :tag => 'option', :attributes => { :value => 'desc', - :selected => 'selected' } } + assert_select 'select[name=?]', 'query[sort_criteria][0][]' do + assert_select 'option[value=priority][selected=selected]' + assert_select 'option[value=desc][selected=selected]' + end end def test_edit_invalid_query diff --git a/test/functional/repositories_bazaar_controller_test.rb b/test/functional/repositories_bazaar_controller_test.rb index 5da8549df..d49ef589e 100644 --- a/test/functional/repositories_bazaar_controller_test.rb +++ b/test/functional/repositories_bazaar_controller_test.rb @@ -86,7 +86,7 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase :path => repository_path_hash(['doc-mkdir.txt'])[:param] assert_response :success assert_template 'changes' - assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' + assert_select 'h2', :text => /doc-mkdir.txt/ end def test_entry_show @@ -95,10 +95,7 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase assert_response :success assert_template 'entry' # Line 19 - assert_tag :tag => 'th', - :content => /29/, - :attributes => { :class => /line-num/ }, - :sibling => { :tag => 'td', :content => /Show help message/ } + assert_select 'tr#L29 td.line-code', :text => /Show help message/ end def test_entry_download @@ -126,11 +123,7 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 11 removed - assert_tag :tag => 'th', - :content => '11', - :sibling => { :tag => 'td', - :attributes => { :class => /diff_out/ }, - :content => /Display more information/ } + assert_select 'th.line-num:content(11) ~ td.diff_out', :text => /Display more information/ end end diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index ece5de781..50a0c8676 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -33,7 +33,7 @@ class RepositoriesControllerTest < ActionController::TestCase assert_template 'new' assert_kind_of Repository::Subversion, assigns(:repository) assert assigns(:repository).new_record? - assert_tag 'input', :attributes => {:name => 'repository[url]', :disabled => nil} + assert_select 'input[name=?]:not([disabled])', 'repository[url]' end def test_new_should_propose_enabled_scm_only @@ -44,12 +44,12 @@ class RepositoriesControllerTest < ActionController::TestCase assert_response :success assert_template 'new' assert_kind_of Repository::Mercurial, assigns(:repository) - assert_tag 'select', :attributes => {:name => 'repository_scm'}, - :children => {:count => 3} - assert_tag 'select', :attributes => {:name => 'repository_scm'}, - :child => {:tag => 'option', :attributes => {:value => 'Mercurial', :selected => 'selected'}} - assert_tag 'select', :attributes => {:name => 'repository_scm'}, - :child => {:tag => 'option', :attributes => {:value => 'Git', :selected => nil}} + + assert_select 'select[name=repository_scm]' do + assert_select 'option', 3 + assert_select 'option[value=Mercurial][selected=selected]' + assert_select 'option[value=Git]:not([selected])' + end end def test_create @@ -84,7 +84,7 @@ class RepositoriesControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' assert_equal Repository.find(11), assigns(:repository) - assert_tag 'input', :attributes => {:name => 'repository[url]', :value => 'svn://localhost/test', :disabled => 'disabled'} + assert_select 'input[name=?][value=?][disabled=disabled]', 'repository[url]', 'svn://localhost/test' end def test_update @@ -170,20 +170,18 @@ class RepositoriesControllerTest < ActionController::TestCase get :revision, :id => 1, :rev => 1 assert_response :success - assert_tag 'a', :attributes => {:href => '/projects/ecookbook/repository', :class => /repository/}, - :ancestor => {:attributes => {:id => 'main-menu'}} + assert_select '#main-menu a.repository[href=?]', '/projects/ecookbook/repository' end def test_revision_with_before_nil_and_afer_normal get :revision, {:id => 1, :rev => 1} assert_response :success assert_template 'revision' - assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, - :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'} - } - assert_tag :tag => "div", :attributes => { :class => "contextual" }, - :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'} - } + + assert_select 'div.contextual' do + assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/0', 0 + assert_select 'a[href=?]', '/projects/ecookbook/repository/revisions/2' + end end def test_add_related_issue @@ -265,17 +263,14 @@ class RepositoriesControllerTest < ActionController::TestCase assert_response :success assert_template 'committers' - assert_tag :td, :content => 'dlopper', - :sibling => { :tag => 'td', - :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }, - :child => { :tag => 'option', :content => 'Dave Lopper', - :attributes => { :value => '3', :selected => 'selected' }}}} - assert_tag :td, :content => 'foo', - :sibling => { :tag => 'td', - :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}} - assert_no_tag :td, :content => 'foo', - :sibling => { :tag => 'td', - :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}} + assert_select 'td:content(dlopper) + td select' do + assert_select 'option[value="3"][selected=selected]', :text => 'Dave Lopper' + end + + assert_select 'td:content(foo) + td select' do + assert_select 'option[value=""]' + assert_select 'option[selected=selected]', 0 # no option selected + end end def test_post_committers diff --git a/test/functional/repositories_cvs_controller_test.rb b/test/functional/repositories_cvs_controller_test.rb index 5e245bc1b..65be94db0 100644 --- a/test/functional/repositories_cvs_controller_test.rb +++ b/test/functional/repositories_cvs_controller_test.rb @@ -112,9 +112,7 @@ class RepositoriesCvsControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success assert_template 'entry' - assert_no_tag :tag => 'td', - :attributes => { :class => /line-code/}, - :content => /before_filter/ + assert_select 'td.line-code', :text => /before_filter/, :count => 0 end def test_entry_at_given_revision @@ -129,9 +127,7 @@ class RepositoriesCvsControllerTest < ActionController::TestCase assert_response :success assert_template 'entry' # this line was removed in r3 - assert_tag :tag => 'td', - :attributes => { :class => /line-code/}, - :content => /before_filter/ + assert_select 'td.line-code', :text => /before_filter/ end def test_entry_not_found @@ -141,9 +137,7 @@ class RepositoriesCvsControllerTest < ActionController::TestCase assert_equal NUM_REV, @repository.changesets.count get :entry, :id => PRJ_ID, :path => repository_path_hash(['sources', 'zzz.c'])[:param] - assert_tag :tag => 'p', - :attributes => { :id => /errorExplanation/ }, - :content => /The entry or revision was not found in the repository/ + assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/ end def test_entry_download @@ -179,10 +173,8 @@ class RepositoriesCvsControllerTest < ActionController::TestCase get :diff, :id => PRJ_ID, :rev => 3, :type => dt assert_response :success assert_template 'diff' - assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, - :content => /before_filter :require_login/ - assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, - :content => /with one change/ + assert_select 'td.line-code.diff_out', :text => /before_filter :require_login/ + assert_select 'td.line-code.diff_in', :text => /with one change/ end end @@ -195,16 +187,11 @@ class RepositoriesCvsControllerTest < ActionController::TestCase get :diff, :id => PRJ_ID, :rev => 1, :type => dt assert_response :success assert_template 'diff' - assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, - :content => /watched.remove_watcher/ - assert_tag :tag => 'th', :attributes => { :class => 'filename' }, - :content => /test\/README/ - assert_tag :tag => 'th', :attributes => { :class => 'filename' }, - :content => /test\/images\/delete.png/ - assert_tag :tag => 'th', :attributes => { :class => 'filename' }, - :content => /test\/images\/edit.png/ - assert_tag :tag => 'th', :attributes => { :class => 'filename' }, - :content => /test\/sources\/watchers_controller.rb/ + assert_select 'td.line-code.diff_in', :text => /watched.remove_watcher/ + assert_select 'th.filename', :text => /test\/README/ + assert_select 'th.filename', :text => /test\/images\/delete.png/ + assert_select 'th.filename', :text => /test\/images\/edit.png/ + assert_select 'th.filename', :text => /test\/sources\/watchers_controller.rb/ end end diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb index 3548dfa3b..cca7d008b 100644 --- a/test/functional/repositories_darcs_controller_test.rb +++ b/test/functional/repositories_darcs_controller_test.rb @@ -102,7 +102,7 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase :path => repository_path_hash(['images', 'edit.png'])[:param] assert_response :success assert_template 'changes' - assert_tag :tag => 'h2', :content => 'edit.png' + assert_select 'h2', :text => /edit.png/ end def test_diff @@ -116,11 +116,7 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 22 removed - assert_tag :tag => 'th', - :content => '22', - :sibling => { :tag => 'td', - :attributes => { :class => /diff_out/ }, - :content => /def remove/ } + assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ end end diff --git a/test/functional/repositories_filesystem_controller_test.rb b/test/functional/repositories_filesystem_controller_test.rb index ee904d8e5..95b93732f 100644 --- a/test/functional/repositories_filesystem_controller_test.rb +++ b/test/functional/repositories_filesystem_controller_test.rb @@ -61,19 +61,16 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase assert_not_nil assigns(:changesets) assert assigns(:changesets).size == 0 - assert_no_tag 'input', :attributes => {:name => 'rev'} - assert_no_tag 'a', :content => 'Statistics' - assert_no_tag 'a', :content => 'Atom' + assert_select 'input[name=rev]', 0 + assert_select 'a', :text => 'Statistics', :count => 0 + assert_select 'a', :text => 'Atom', :count => 0 end def test_show_no_extension get :entry, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param] assert_response :success assert_template 'entry' - assert_tag :tag => 'th', - :content => '1', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /TEST CAT/ } + assert_select 'tr#L1 td.line-code', :text => /TEST CAT/ end def test_entry_download_no_extension @@ -88,20 +85,14 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase :path => repository_path_hash(['japanese', 'euc-jp.txt'])[:param] assert_response :success assert_template 'entry' - assert_tag :tag => 'th', - :content => '2', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /japanese/ } + assert_select 'tr#L2 td.line-code', :text => /japanese/ if @ruby19_non_utf8_pass puts "TODO: show repository file contents test fails " + "when Encoding.default_external is not UTF-8. " + "Current value is '#{Encoding.default_external.to_s}'" else str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e".force_encoding('UTF-8') - assert_tag :tag => 'th', - :content => '3', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /#{str_japanese}/ } + assert_select 'tr#L3 td.line-code', :text => /#{str_japanese}/ end end end @@ -112,10 +103,7 @@ class RepositoriesFilesystemControllerTest < ActionController::TestCase get :entry, :id => PRJ_ID, :path => repository_path_hash(['japanese', 'utf-16.txt'])[:param] assert_response :success - assert_tag :tag => 'th', - :content => '2', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /japanese/ } + assert_select 'tr#L2 td.line-code', :text => /japanese/ end end diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index e20adeab5..654c81255 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -198,7 +198,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase :path => repository_path_hash(['images', 'edit.png'])[:param] assert_response :success assert_template 'changes' - assert_tag :tag => 'h2', :content => 'edit.png' + assert_select 'h2', :text => /edit.png/ end def test_entry_show @@ -206,11 +206,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success assert_template 'entry' - # Line 19 - assert_tag :tag => 'th', - :content => '11', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } + # Line 11 + assert_select 'tr#L11 td.line-code', :text => /WITHOUT ANY WARRANTY/ end def test_entry_show_latin_1 @@ -228,11 +225,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase :rev => r1 assert_response :success assert_template 'entry' - assert_tag :tag => 'th', - :content => '1', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', - :content => /test-#{CHAR_1_HEX}.txt/ } + assert_select 'tr#L1 td.line-code', :text => /test-#{CHAR_1_HEX}.txt/ end end end @@ -272,12 +265,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 22 removed - assert_tag :tag => 'th', - :content => /22/, - :sibling => { :tag => 'td', - :attributes => { :class => /diff_out/ }, - :content => /def remove/ } - assert_tag :tag => 'h2', :content => /2f9c0091/ + assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'h2', :text => /2f9c0091/ end end @@ -297,12 +286,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 22 removed - assert_tag :tag => 'th', - :content => '22', - :sibling => { :tag => 'td', - :attributes => { :class => /diff_out/ }, - :content => /def remove/ } - assert_tag :tag => 'h2', :content => /2f9c0091/ + assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'h2', :text => /2f9c0091/ end end end @@ -348,19 +333,9 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_template 'diff' diff = assigns(:diff) assert_not_nil diff - assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/ - assert_tag :tag => "form", - :attributes => { - :action => "/projects/subproject1/repository/revisions/" + - "61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff" - } - assert_tag :tag => 'input', - :attributes => { - :id => "rev_to", - :name => "rev_to", - :type => "hidden", - :value => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' - } + assert_select 'h2', :text => /2f9c0091:61b685fb/ + assert_select 'form[action=?]', '/projects/subproject1/repository/revisions/61b685fbe55ab05b5ac68402d5720c1a6ac973d1/diff' + assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91af7a9c478e36556b4bde8dcf7' end end @@ -384,18 +359,8 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_template 'diff' diff = assigns(:diff) assert_not_nil diff - assert_tag :tag => "form", - :attributes => { - :action => "/projects/subproject1/repository/test-diff-path/" + - "revisions/61b685fbe55ab05b/diff" - } - assert_tag :tag => 'input', - :attributes => { - :id => "rev_to", - :name => "rev_to", - :type => "hidden", - :value => '2f9c0091c754a91a' - } + assert_select 'form[action=?]', '/projects/subproject1/repository/test-diff-path/revisions/61b685fbe55ab05b/diff' + assert_select 'input#rev_to[type=hidden][name=rev_to][value=?]', '2f9c0091c754a91a' end def test_diff_latin_1 @@ -408,20 +373,10 @@ class RepositoriesGitControllerTest < ActionController::TestCase get :diff, :id => PRJ_ID, :rev => r1, :type => dt assert_response :success assert_template 'diff' - assert_tag :tag => 'thead', - :descendant => { - :tag => 'th', - :attributes => { :class => 'filename' } , - :content => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/ , - }, - :sibling => { - :tag => 'tbody', - :descendant => { - :tag => 'td', - :attributes => { :class => /diff_in/ }, - :content => /test-#{CHAR_1_HEX}.txt/ - } - } + assert_select 'table' do + assert_select 'thead th.filename', :text => /latin-1-dir\/test-#{CHAR_1_HEX}.txt/ + assert_select 'tbody td.diff_in', :text => /test-#{CHAR_1_HEX}.txt/ + end end end end @@ -487,7 +442,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success assert_template 'annotate' - assert_tag :tag => 'h2', :content => /@ deff712f/ + assert_select 'h2', :text => /@ deff712f/ end def test_annotate_binary_file @@ -495,8 +450,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase get :annotate, :id => PRJ_ID, :path => repository_path_hash(['images', 'edit.png'])[:param] assert_response 500 - assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, - :content => /cannot be annotated/ + assert_select 'p#errorExplanation', :text => /cannot be annotated/ end end @@ -506,8 +460,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param], :rev => 'deff712f' assert_response 500 - assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, - :content => /exceeds the maximum text file size/ + assert_select 'p#errorExplanation', :text => /exceeds the maximum text file size/ get :annotate, :id => PRJ_ID, :path => repository_path_hash(['README'])[:param], @@ -569,11 +522,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase get :revisions, :id => PRJ_ID assert_response :success assert_template 'revisions' - assert_tag :tag => 'form', - :attributes => { - :method => 'get', - :action => '/projects/subproject1/repository/revision' - } + assert_select 'form[method=get][action=?]', '/projects/subproject1/repository/revision' end def test_revision @@ -596,7 +545,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase ['', ' ', nil].each do |r| get :revision, :id => PRJ_ID, :rev => r assert_response 404 - assert_error_tag :content => /was not found/ + assert_select_error /was not found/ end end diff --git a/test/functional/repositories_mercurial_controller_test.rb b/test/functional/repositories_mercurial_controller_test.rb index 382aa5ccf..b0afb7a62 100644 --- a/test/functional/repositories_mercurial_controller_test.rb +++ b/test/functional/repositories_mercurial_controller_test.rb @@ -164,10 +164,11 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase @repository.fetch_changesets @project.reload get :show, :id => PRJ_ID - assert_tag 'form', :attributes => {:id => 'revision_selector', :action => '/projects/subproject1/repository/show'} - assert_tag 'select', :attributes => {:name => 'branch'}, - :child => {:tag => 'option', :attributes => {:value => 'test-branch-01'}}, - :parent => {:tag => 'form', :attributes => {:id => 'revision_selector'}} + assert_select 'form#revision_selector[action=?]', '/projects/subproject1/repository/show' do + assert_select 'select[name=branch]' do + assert_select 'option[value=?]', 'test-branch-01' + end + end end def test_show_branch @@ -218,7 +219,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :path => repository_path_hash(['images', 'edit.png'])[:param] assert_response :success assert_template 'changes' - assert_tag :tag => 'h2', :content => 'edit.png' + assert_select 'h2', :text => /edit.png/ end def test_entry_show @@ -227,10 +228,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase assert_response :success assert_template 'entry' # Line 10 - assert_tag :tag => 'th', - :content => '10', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } + assert_select 'tr#L10 td.line-code', :text => /WITHOUT ANY WARRANTY/ end def test_entry_show_latin_1_path @@ -240,11 +238,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :rev => r1 assert_response :success assert_template 'entry' - assert_tag :tag => 'th', - :content => '1', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', - :content => /Mercurial is a distributed version control system/ } + assert_select 'tr#L1 td.line-code', :text => /Mercurial is a distributed version control system/ end end @@ -256,11 +250,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :rev => r1 assert_response :success assert_template 'entry' - assert_tag :tag => 'th', - :content => '1', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', - :content => /test-#{@char_1}.txt/ } + assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ end end end @@ -303,12 +293,8 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase assert_template 'diff' if @diff_c_support # Line 22 removed - assert_tag :tag => 'th', - :content => '22', - :sibling => { :tag => 'td', - :attributes => { :class => /diff_out/ }, - :content => /def remove/ } - assert_tag :tag => 'h2', :content => /4:def6d2f1254a/ + assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'h2', :text => /4:def6d2f1254a/ end end end @@ -331,8 +317,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase assert_template 'diff' diff = assigns(:diff) assert_not_nil diff - assert_tag :tag => 'h2', - :content => /4:def6d2f1254a 2:400bb8672109/ + assert_select 'h2', :text => /4:def6d2f1254a 2:400bb8672109/ end end end @@ -345,20 +330,10 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase get :diff, :id => PRJ_ID, :rev => r1, :type => dt assert_response :success assert_template 'diff' - assert_tag :tag => 'thead', - :descendant => { - :tag => 'th', - :attributes => { :class => 'filename' } , - :content => /latin-1-dir\/test-#{@char_1}-2.txt/ , - }, - :sibling => { - :tag => 'tbody', - :descendant => { - :tag => 'td', - :attributes => { :class => /diff_in/ }, - :content => /It is written in Python/ - } - } + 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/ + end end end end @@ -401,7 +376,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase get :annotate, :id => PRJ_ID, :path => repository_path_hash(['sources', 'welcome_controller.rb'])[:param] assert_response 404 - assert_error_tag :content => /was not found/ + assert_select_error /was not found/ end def test_annotate_at_given_revision @@ -414,7 +389,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase :path => repository_path_hash(['sources', 'watchers_controller.rb'])[:param] assert_response :success assert_template 'annotate' - assert_tag :tag => 'h2', :content => /@ 2:400bb8672109/ + assert_select 'h2', :text => /@ 2:400bb8672109/ end end @@ -443,11 +418,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase get :annotate, :id => PRJ_ID, :path => repository_path_hash(['latin-1-dir', "test-#{@char_1}.txt"])[:param], :rev => r1 - assert_tag :tag => 'th', - :content => '1', - :attributes => { :class => 'line-num' }, - :sibling => { :tag => 'td', - :content => /test-#{@char_1}.txt/ } + assert_select 'tr#L1 td.line-code', :text => /test-#{@char_1}.txt/ end end end @@ -476,7 +447,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase ['', ' ', nil].each do |r| get :revision, :id => PRJ_ID, :rev => r assert_response 404 - assert_error_tag :content => /was not found/ + assert_select_error /was not found/ end end diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb index 66522d6e5..919de501d 100644 --- a/test/functional/repositories_subversion_controller_test.rb +++ b/test/functional/repositories_subversion_controller_test.rb @@ -64,12 +64,10 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase assert_equal 'dir', entry.kind assert_select 'tr.dir a[href="/projects/subproject1/repository/show/subversion_test"]' - assert_tag 'input', :attributes => {:name => 'rev'} - assert_tag 'a', :content => 'Statistics' - assert_tag 'a', :content => 'Atom' - assert_tag :tag => 'a', - :attributes => {:href => '/projects/subproject1/repository'}, - :content => 'root' + assert_select 'input[name=rev]' + assert_select 'a', :text => 'Statistics' + assert_select 'a', :text => 'Atom' + assert_select 'a[href=?]', '/projects/subproject1/repository', :text => 'root' end def test_show_non_default @@ -102,7 +100,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase 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/ } + assert_select 'a.text-x-c', :text => 'helloworld.c' end def test_browse_at_given_revision @@ -137,10 +135,10 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase 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_tag :ul, - :child => { :tag => 'li', - :child => { :tag => 'b', :content => 'svn:eol-style' }, - :child => { :tag => 'span', :content => 'native' } } + assert_select 'ul li' do + assert_select 'b', :text => 'svn:eol-style' + assert_select 'span', :text => 'native' + end end end @@ -203,8 +201,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase 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/ + assert_select 'td.line-code', :text => /Here's the code/ end def test_entry_not_found @@ -214,8 +211,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase assert_equal NUM_REV, @repository.changesets.count get :entry, :id => PRJ_ID, :path => repository_path_hash(['subversion_test', 'zzz.c'])[:param] - assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, - :content => /The entry or revision was not found in the repository/ + assert_select 'p#errorExplanation', :text => /The entry or revision was not found in the repository/ end def test_entry_download @@ -265,13 +261,13 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase assert_equal NUM_REV, @repository.changesets.count get :revision, :id => PRJ_ID, :rev => 'something_weird' assert_response 404 - assert_error_tag :content => /was not found/ + assert_select_error /was not found/ end def test_invalid_revision_diff get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' assert_response 404 - assert_error_tag :content => /was not found/ + assert_select_error /was not found/ end def test_empty_revision @@ -282,7 +278,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase ['', ' ', nil].each do |r| get :revision, :id => PRJ_ID, :rev => r assert_response 404 - assert_error_tag :content => /was not found/ + assert_select_error /was not found/ end end @@ -348,7 +344,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase assert_not_nil diff # 2 files modified assert_equal 2, Redmine::UnifiedDiff.new(diff).size - assert_tag :tag => 'h2', :content => /2:6/ + assert_select 'h2', :text => /2:6/ end end @@ -385,7 +381,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] assert_response :success assert_template 'annotate' - assert_tag :tag => 'h2', :content => /@ 8/ + assert_select 'h2', :text => /@ 8/ end def test_destroy_valid_repository diff --git a/test/functional/roles_controller_test.rb b/test/functional/roles_controller_test.rb index ddd231dcf..16f0f2537 100644 --- a/test/functional/roles_controller_test.rb +++ b/test/functional/roles_controller_test.rb @@ -33,8 +33,7 @@ class RolesControllerTest < ActionController::TestCase assert_not_nil assigns(:roles) assert_equal Role.order('builtin, position').to_a, assigns(:roles) - assert_tag :tag => 'a', :attributes => { :href => '/roles/1/edit' }, - :content => 'Manager' + assert_select 'a[href="/roles/1/edit"]', :text => 'Manager' end def test_new @@ -75,7 +74,7 @@ class RolesControllerTest < ActionController::TestCase assert_response :success assert_template 'new' - assert_tag :tag => 'div', :attributes => { :id => 'errorExplanation' } + assert_select 'div#errorExplanation' end def test_create_without_workflow_copy @@ -162,15 +161,8 @@ class RolesControllerTest < ActionController::TestCase assert_not_nil assigns(:roles) assert_equal Role.order('builtin, position').to_a, assigns(:roles) - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'permissions[3][]', - :value => 'add_issues', - :checked => 'checked' } - - assert_tag :tag => 'input', :attributes => { :type => 'checkbox', - :name => 'permissions[3][]', - :value => 'delete_issues', - :checked => nil } + assert_select 'input[name=?][type=checkbox][value=add_issues][checked=checked]', 'permissions[3][]' + assert_select 'input[name=?][type=checkbox][value=delete_issues]:not([checked])', 'permissions[3][]' end def test_post_permissions diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 5b8e1acc4..baf37deee 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -49,13 +49,12 @@ class SearchControllerTest < ActionController::TestCase assert assigns(:results).include?(Issue.find(2)) assert assigns(:results).include?(Issue.find(5)) assert assigns(:results).include?(Changeset.find(101)) - assert_tag :dt, :attributes => { :class => /issue/ }, - :child => { :tag => 'a', :content => /Add ingredients categories/ }, - :sibling => { :tag => 'dd', :content => /should be classified by categories/ } + assert_select 'dt.issue a', :text => /Add ingredients categories/ + assert_select 'dd', :text => /should be classified by categories/ assert assigns(:results_by_type).is_a?(Hash) assert_equal 5, assigns(:results_by_type)['changesets'] - assert_tag :a, :content => 'Changesets (5)' + assert_select 'a', :text => 'Changesets (5)' end def test_search_issues @@ -67,8 +66,7 @@ class SearchControllerTest < ActionController::TestCase assert_equal false, assigns(:titles_only) assert assigns(:results).include?(Issue.find(8)) assert assigns(:results).include?(Issue.find(5)) - assert_tag :dt, :attributes => { :class => /issue closed/ }, - :child => { :tag => 'a', :content => /Closed/ } + assert_select 'dt.issue.closed a', :text => /Closed/ end def test_search_issues_should_search_notes diff --git a/test/functional/settings_controller_test.rb b/test/functional/settings_controller_test.rb index e7fe29780..615eae47d 100644 --- a/test/functional/settings_controller_test.rb +++ b/test/functional/settings_controller_test.rb @@ -37,7 +37,7 @@ class SettingsControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_tag 'input', :attributes => {:name => 'settings[enabled_scm][]', :value => ''} + assert_select 'input[name=?][value=""]', 'settings[enabled_scm][]' end def test_get_edit_should_preselect_default_issue_list_columns @@ -146,9 +146,9 @@ class SettingsControllerTest < ActionController::TestCase get :plugin, :id => 'foo' assert_response :success assert_template 'plugin' - assert_tag 'form', :attributes => {:action => '/settings/plugin/foo'}, - :descendant => {:tag => 'input', :attributes => {:name => 'settings[sample_setting]', :value => 'Plugin setting value'}} - + assert_select 'form[action="/settings/plugin/foo"]' do + assert_select 'input[name=?][value=?]', 'settings[sample_setting]', 'Plugin setting value' + end ensure Redmine::Plugin.unregister(:foo) end diff --git a/test/functional/sys_controller_test.rb b/test/functional/sys_controller_test.rb index de9c7c5e1..3710e7c3b 100644 --- a/test/functional/sys_controller_test.rb +++ b/test/functional/sys_controller_test.rb @@ -33,12 +33,16 @@ class SysControllerTest < ActionController::TestCase get :projects assert_response :success assert_equal 'application/xml', @response.content_type - with_options :tag => 'projects' do |test| - test.assert_tag :children => { :count => Project.active.has_module(:repository).count } - test.assert_tag 'project', :child => {:tag => 'identifier', :sibling => {:tag => 'is-public'}} + + assert_select 'projects' do + assert_select 'project', Project.active.has_module(:repository).count + assert_select 'project' do + assert_select 'identifier' + assert_select 'is-public' + end end - assert_no_tag 'extra-info' - assert_no_tag 'extra_info' + assert_select 'extra-info', 0 + assert_select 'extra_info', 0 end def test_create_project_repository @@ -54,13 +58,12 @@ class SysControllerTest < ActionController::TestCase assert r.is_a?(Repository::Subversion) assert_equal 'file:///create/project/repository/subproject2', r.url - assert_tag 'repository-subversion', - :child => { - :tag => 'id', :content => r.id.to_s, - :sibling => {:tag => 'url', :content => r.url} - } - assert_no_tag 'extra-info' - assert_no_tag 'extra_info' + assert_select 'repository-subversion' do + assert_select 'id', :text => r.id.to_s + assert_select 'url', :text => r.url + end + assert_select 'extra-info', 0 + assert_select 'extra_info', 0 end def test_create_already_existing diff --git a/test/functional/time_entry_reports_controller_test.rb b/test/functional/time_entry_reports_controller_test.rb index 16a477079..e8551a9ba 100644 --- a/test/functional/time_entry_reports_controller_test.rb +++ b/test/functional/time_entry_reports_controller_test.rb @@ -37,16 +37,14 @@ class TimeEntryReportsControllerTest < ActionController::TestCase get :report, :project_id => 'ecookbook' assert_response :success assert_template 'report' - assert_tag :form, - :attributes => {:action => "/projects/ecookbook/time_entries/report", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries/report' end def test_report_all_projects get :report assert_response :success assert_template 'report' - assert_tag :form, - :attributes => {:action => "/time_entries/report", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/time_entries/report' end def test_report_all_projects_denied @@ -80,7 +78,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase assert_template 'report' assert_not_nil assigns(:report) assert_equal "162.90", "%.2f" % assigns(:report).total_hours - assert_tag :tag => 'th', :content => '2007-03-12' + assert_select 'th', :text => '2007-03-12' end def test_report_one_criteria @@ -135,8 +133,7 @@ class TimeEntryReportsControllerTest < ActionController::TestCase assert_template 'report' assert_not_nil assigns(:report) assert_equal "154.25", "%.2f" % assigns(:report).total_hours - assert_tag :form, - :attributes => {:action => "/issues/1/time_entries/report", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/issues/1/time_entries/report' end def test_report_by_week_should_use_commercial_year @@ -209,8 +206,8 @@ class TimeEntryReportsControllerTest < ActionController::TestCase get :report, :project_id => 1, :criteria => ['status'] assert_response :success assert_template 'report' - assert_tag :tag => 'th', :content => 'Status' - assert_tag :tag => 'td', :content => 'New' + assert_select 'th', :text => 'Status' + assert_select 'td', :text => 'New' end def test_report_all_projects_csv_export diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index a60bd2b6b..978503b4e 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -92,7 +92,7 @@ class TimelogControllerTest < ActionController::TestCase @request.session[:user_id] = 3 get :new, :project_id => 1 assert_response :success - assert_no_tag 'option', :content => 'Inactive Activity' + assert_select 'option', :text => 'Inactive Activity', :count => 0 end def test_get_edit_existing_time @@ -100,7 +100,7 @@ class TimelogControllerTest < ActionController::TestCase get :edit, :id => 2, :project_id => nil assert_response :success assert_template 'edit' - assert_tag :tag => 'form', :attributes => { :action => '/time_entries/2' } + assert_select 'form[action=?]', '/time_entries/2' end def test_get_edit_with_an_existing_time_entry_with_inactive_activity @@ -113,7 +113,7 @@ class TimelogControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' # Blank option since nothing is pre-selected - assert_tag :tag => 'option', :content => '--- Please select ---' + assert_select 'option', :text => '--- Please select ---' end def test_post_create @@ -301,8 +301,9 @@ class TimelogControllerTest < ActionController::TestCase end assert_response :success - assert_tag 'select', :attributes => {:name => 'time_entry[project_id]'}, - :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}} + assert_select 'select[name=?]', 'time_entry[project_id]' do + assert_select 'option[value="1"][selected=selected]' + end end def test_update @@ -472,8 +473,7 @@ class TimelogControllerTest < ActionController::TestCase assert_template 'index' assert_not_nil assigns(:total_hours) assert_equal "162.90", "%.2f" % assigns(:total_hours) - assert_tag :form, - :attributes => {:action => "/time_entries", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/time_entries' end def test_index_all_projects_should_show_log_time_link @@ -481,7 +481,7 @@ class TimelogControllerTest < ActionController::TestCase get :index assert_response :success assert_template 'index' - assert_tag 'a', :attributes => {:href => '/time_entries/new'}, :content => /Log time/ + assert_select 'a[href=?]', '/time_entries/new', :text => /Log time/ end def test_index_my_spent_time @@ -502,8 +502,7 @@ class TimelogControllerTest < ActionController::TestCase assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort assert_not_nil assigns(:total_hours) assert_equal "162.90", "%.2f" % assigns(:total_hours) - assert_tag :form, - :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' end def test_index_with_display_subprojects_issues_to_false_should_not_include_subproject_entries @@ -539,8 +538,7 @@ class TimelogControllerTest < ActionController::TestCase assert_equal 3, assigns(:entries).size assert_not_nil assigns(:total_hours) assert_equal "12.90", "%.2f" % assigns(:total_hours) - assert_tag :form, - :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' end def test_index_at_project_level_with_date_range_using_from_and_to_params @@ -551,8 +549,7 @@ class TimelogControllerTest < ActionController::TestCase assert_equal 3, assigns(:entries).size assert_not_nil assigns(:total_hours) assert_equal "12.90", "%.2f" % assigns(:total_hours) - assert_tag :form, - :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' end def test_index_at_project_level_with_period @@ -564,8 +561,7 @@ class TimelogControllerTest < ActionController::TestCase assert_template 'index' assert_not_nil assigns(:entries) assert_not_nil assigns(:total_hours) - assert_tag :form, - :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/projects/ecookbook/time_entries' end def test_index_at_issue_level @@ -579,8 +575,7 @@ class TimelogControllerTest < ActionController::TestCase # display all time assert_nil assigns(:from) assert_nil assigns(:to) - assert_tag :form, - :attributes => {:action => "/issues/1/time_entries", :id => 'query_form'} + assert_select 'form#query_form[action=?]', '/issues/1/time_entries' end def test_index_should_sort_by_spent_on_and_created_on diff --git a/test/functional/trackers_controller_test.rb b/test/functional/trackers_controller_test.rb index ca2619e1f..e69700dfc 100644 --- a/test/functional/trackers_controller_test.rb +++ b/test/functional/trackers_controller_test.rb @@ -89,7 +89,7 @@ class TrackersControllerTest < ActionController::TestCase end assert_response :success assert_template 'new' - assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i + assert_select_error /name #{ESCAPED_CANT} be blank/i end def test_edit @@ -99,17 +99,10 @@ class TrackersControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', - :value => '1', - :checked => 'checked' } + assert_select 'input[name=?][value="1"][checked=checked]', 'tracker[project_ids][]' + assert_select 'input[name=?][value="2"]:not([checked])', 'tracker[project_ids][]' - assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', - :value => '2', - :checked => nil } - - assert_tag :input, :attributes => { :name => 'tracker[project_ids][]', - :value => '', - :type => 'hidden'} + assert_select 'input[name=?][value=""][type=hidden]', 'tracker[project_ids][]' end def test_edit_should_check_core_fields @@ -154,7 +147,7 @@ class TrackersControllerTest < ActionController::TestCase put :update, :id => 1, :tracker => { :name => '' } assert_response :success assert_template 'edit' - assert_error_tag :content => /name #{ESCAPED_CANT} be blank/i + assert_select_error /name #{ESCAPED_CANT} be blank/i end def test_move_lower diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 50334931b..3306e2fad 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -75,7 +75,7 @@ class UsersControllerTest < ActionController::TestCase assert_template 'show' assert_not_nil assigns(:user) - assert_tag 'li', :content => /Phone number/ + assert_select 'li', :text => /Phone number/ end def test_show_should_not_display_hidden_custom_fields @@ -86,7 +86,7 @@ class UsersControllerTest < ActionController::TestCase assert_template 'show' assert_not_nil assigns(:user) - assert_no_tag 'li', :content => /Phone number/ + assert_select 'li', :text => /Phone number/, :count => 0 end def test_show_should_not_fail_when_custom_values_are_nil diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb index 6ac170f29..5c0d1dba2 100644 --- a/test/functional/versions_controller_test.rb +++ b/test/functional/versions_controller_test.rb @@ -95,7 +95,7 @@ class VersionsControllerTest < ActionController::TestCase assert_template 'show' assert_not_nil assigns(:version) - assert_tag :tag => 'h2', :content => /1.0/ + assert_select 'h2', :text => /1.0/ end def test_show_should_display_nil_counts diff --git a/test/functional/welcome_controller_test.rb b/test/functional/welcome_controller_test.rb index 2fd188c37..4f2ce8f72 100644 --- a/test/functional/welcome_controller_test.rb +++ b/test/functional/welcome_controller_test.rb @@ -107,9 +107,7 @@ class WelcomeControllerTest < ActionController::TestCase @request.session[:user_id] = 2 get :index - assert_no_tag 'script', - :attributes => {:type => "text/javascript"}, - :content => %r{warnLeavingUnsaved} + assert_select 'script', :text => %r{warnLeavingUnsaved}, :count => 0 end def test_logout_link_should_post diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 19bfa78e8..d16a1559c 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -31,31 +31,28 @@ class WikiControllerTest < ActionController::TestCase get :show, :project_id => 'ecookbook' assert_response :success assert_template 'show' - assert_tag :tag => 'h1', :content => /CookBook documentation/ + assert_select 'h1', :text => /CookBook documentation/ # child_pages macro - assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, - :child => { :tag => 'li', - :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, - :content => 'Page with an inline image' } } + assert_select 'ul.pages-hierarchy>li>a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', + :text => 'Page with an inline image' end def test_export_link Role.anonymous.add_permission! :export_wiki_pages get :show, :project_id => 'ecookbook' assert_response :success - assert_tag 'a', :attributes => {:href => '/projects/ecookbook/wiki/CookBook_documentation.txt'} + assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation.txt' end def test_show_page_with_name get :show, :project_id => 1, :id => 'Another_page' assert_response :success assert_template 'show' - assert_tag :tag => 'h1', :content => /Another page/ + assert_select 'h1', :text => /Another page/ # Included page with an inline image - assert_tag :tag => 'p', :content => /This is an inline image/ - assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3/logo.gif', - :alt => 'This is a logo' } + assert_select 'p', :text => /This is an inline image/ + assert_select 'img[src=?][alt=?]', '/attachments/download/3/logo.gif', 'This is a logo' end def test_show_old_version @@ -118,40 +115,30 @@ class WikiControllerTest < ActionController::TestCase get :show, :project_id => 1, :id => 'Another_page' assert_response :success - assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, - :content => /Side bar content for test_show_with_sidebar/ + assert_select 'div#sidebar', :text => /Side bar content for test_show_with_sidebar/ end def test_show_should_display_section_edit_links @request.session[:user_id] = 2 get :show, :project_id => 1, :id => 'Page with sections' - assert_no_tag 'a', :attributes => { - :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=1' - } - assert_tag 'a', :attributes => { - :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' - } - assert_tag 'a', :attributes => { - :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=3' - } + + assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=1', 0 + assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' + assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=3' end def test_show_current_version_should_display_section_edit_links @request.session[:user_id] = 2 get :show, :project_id => 1, :id => 'Page with sections', :version => 3 - assert_tag 'a', :attributes => { - :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' - } + assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' end def test_show_old_version_should_not_display_section_edit_links @request.session[:user_id] = 2 get :show, :project_id => 1, :id => 'Page with sections', :version => 2 - assert_no_tag 'a', :attributes => { - :href => '/projects/ecookbook/wiki/Page_with_sections/edit?section=2' - } + assert_select 'a[href=?]', '/projects/ecookbook/wiki/Page_with_sections/edit?section=2', 0 end def test_show_unexistent_page_without_edit_right @@ -176,8 +163,7 @@ class WikiControllerTest < ActionController::TestCase get :show, :project_id => 1, :id => 'Unexistent page', :parent => 'Another_page' assert_response :success assert_template 'edit' - assert_tag 'select', :attributes => {:name => 'wiki_page[parent_id]'}, - :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}} + assert_select 'select[name=?] option[value="2"][selected=selected]', 'wiki_page[parent_id]' end def test_show_should_not_show_history_without_permission @@ -251,9 +237,8 @@ class WikiControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_tag 'textarea', - :attributes => { :name => 'content[text]' }, - :content => "\n"+WikiPage.find_by_title('Another_page').content.text + assert_select 'textarea[name=?]', 'content[text]', + :text => WikiPage.find_by_title('Another_page').content.text end def test_edit_section @@ -266,13 +251,9 @@ class WikiControllerTest < ActionController::TestCase page = WikiPage.find_by_title('Page_with_sections') section, hash = Redmine::WikiFormatting::Textile::Formatter.new(page.content.text).get_section(2) - assert_tag 'textarea', - :attributes => { :name => 'content[text]' }, - :content => "\n"+section - assert_tag 'input', - :attributes => { :name => 'section', :type => 'hidden', :value => '2' } - assert_tag 'input', - :attributes => { :name => 'section_hash', :type => 'hidden', :value => hash } + assert_select 'textarea[name=?]', 'content[text]', :text => section + assert_select 'input[name=section][type=hidden][value="2"]' + assert_select 'input[name=section_hash][type=hidden][value=?]', hash end def test_edit_invalid_section_should_respond_with_404 @@ -348,9 +329,9 @@ class WikiControllerTest < ActionController::TestCase assert_response :success assert_template 'edit' - assert_error_tag :descendant => {:content => /Comment is too long/} - assert_tag :tag => 'textarea', :attributes => {:id => 'content_text'}, :content => "\nedited" - assert_tag :tag => 'input', :attributes => {:id => 'content_version', :value => '1'} + assert_select_error /Comment is too long/ + assert_select 'textarea#content_text', :text => "edited" + assert_select 'input#content_version[value="1"]' end def test_update_page_with_parent_change_only_should_not_create_content_version @@ -418,14 +399,9 @@ class WikiControllerTest < ActionController::TestCase end assert_response :success assert_template 'edit' - assert_tag :div, - :attributes => { :class => /error/ }, - :content => /Data has been updated by another user/ - assert_tag 'textarea', - :attributes => { :name => 'content[text]' }, - :content => /Text should not be lost/ - assert_tag 'input', - :attributes => { :name => 'content[comments]', :value => 'My comments' } + assert_select 'div.error', :text => /Data has been updated by another user/ + assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/ + assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments' c.reload assert_equal 'Previous text', c.text @@ -512,14 +488,9 @@ class WikiControllerTest < ActionController::TestCase end assert_response :success assert_template 'edit' - assert_tag :div, - :attributes => { :class => /error/ }, - :content => /Data has been updated by another user/ - assert_tag 'textarea', - :attributes => { :name => 'content[text]' }, - :content => /Text should not be lost/ - assert_tag 'input', - :attributes => { :name => 'content[comments]', :value => 'My comments' } + assert_select 'div.error', :text => /Data has been updated by another user/ + assert_select 'textarea[name=?]', 'content[text]', :text => /Text should not be lost/ + assert_select 'input[name=?][value=?]', 'content[comments]', 'My comments' end def test_preview @@ -530,7 +501,7 @@ class WikiControllerTest < ActionController::TestCase :version => 3 } assert_response :success assert_template 'common/_preview' - assert_tag :tag => 'strong', :content => /previewed text/ + assert_select 'strong', :text => /previewed text/ end def test_preview_new_page @@ -541,7 +512,7 @@ class WikiControllerTest < ActionController::TestCase :version => 0 } assert_response :success assert_template 'common/_preview' - assert_tag :tag => 'h1', :content => /New page/ + assert_select 'h1', :text => /New page/ end def test_history @@ -607,22 +578,18 @@ class WikiControllerTest < ActionController::TestCase assert_template 'annotate' # Line 1 - assert_tag :tag => 'tr', :child => { - :tag => 'th', :attributes => {:class => 'line-num'}, :content => '1', :sibling => { - :tag => 'td', :attributes => {:class => 'author'}, :content => /John Smith/, :sibling => { - :tag => 'td', :content => /h1\. CookBook documentation/ - } - } - } + assert_select 'table.annotate tr:nth-child(1)' do + assert_select 'th.line-num', :text => '1' + assert_select 'td.author', :text => /John Smith/ + assert_select 'td', :text => /h1\. CookBook documentation/ + end # Line 5 - assert_tag :tag => 'tr', :child => { - :tag => 'th', :attributes => {:class => 'line-num'}, :content => '5', :sibling => { - :tag => 'td', :attributes => {:class => 'author'}, :content => /Redmine Admin/, :sibling => { - :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ - } - } - } + assert_select 'table.annotate tr:nth-child(5)' do + assert_select 'th.line-num', :text => '5' + assert_select 'td.author', :text => /Redmine Admin/ + assert_select 'td', :text => /Some updated \[\[documentation\]\] here/ + end end def test_annotate_with_invalid_version_should_respond_with_404 @@ -635,13 +602,11 @@ class WikiControllerTest < ActionController::TestCase get :rename, :project_id => 1, :id => 'Another_page' assert_response :success assert_template 'rename' - assert_tag 'option', - :attributes => {:value => ''}, - :content => '', - :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} - assert_no_tag 'option', - :attributes => {:selected => 'selected'}, - :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} + + assert_select 'select[name=?]', 'wiki_page[parent_id]' do + assert_select 'option[value=""]', :text => '' + assert_select 'option[selected=selected]', 0 + end end def test_get_rename_child_page @@ -649,17 +614,11 @@ class WikiControllerTest < ActionController::TestCase get :rename, :project_id => 1, :id => 'Child_1' assert_response :success assert_template 'rename' - assert_tag 'option', - :attributes => {:value => ''}, - :content => '', - :parent => {:tag => 'select', :attributes => {:name => 'wiki_page[parent_id]'}} - assert_tag 'option', - :attributes => {:value => '2', :selected => 'selected'}, - :content => /Another page/, - :parent => { - :tag => 'select', - :attributes => {:name => 'wiki_page[parent_id]'} - } + + assert_select 'select[name=?]', 'wiki_page[parent_id]' do + assert_select 'option[value=""]', :text => '' + assert_select 'option[value="2"][selected=selected]', :text => /Another page/ + end end def test_rename_with_redirect @@ -771,20 +730,18 @@ class WikiControllerTest < ActionController::TestCase assert_equal Project.find(1).wiki.pages.size, pages.size assert_equal pages.first.content.updated_on, pages.first.updated_on - assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, - :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' }, - :content => 'CookBook documentation' }, - :child => { :tag => 'ul', - :child => { :tag => 'li', - :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, - :content => 'Page with an inline image' } } } }, - :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' }, - :content => 'Another page' } } + assert_select 'ul.pages-hierarchy' do + assert_select 'li' do + assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation', :text => 'CookBook documentation' + assert_select 'ul li a[href=?]', '/projects/ecookbook/wiki/Page_with_an_inline_image', :text => 'Page with an inline image' + end + assert_select 'li a[href=?]', '/projects/ecookbook/wiki/Another_page', :text => 'Another page' + end end def test_index_should_include_atom_link get :index, :project_id => 'ecookbook' - assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} + assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1' end def test_export_to_html @@ -829,7 +786,7 @@ class WikiControllerTest < ActionController::TestCase assert_not_nil assigns(:pages) assert_not_nil assigns(:pages_by_date) - assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} + assert_select 'a[href=?]', '/projects/ecookbook/activity.atom?show_wiki_edits=1' end def test_not_found @@ -860,7 +817,7 @@ class WikiControllerTest < ActionController::TestCase get :show, :project_id => 1 assert_response :success assert_template 'show' - assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } + assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit' end def test_show_page_without_edit_link @@ -868,7 +825,7 @@ class WikiControllerTest < ActionController::TestCase get :show, :project_id => 1 assert_response :success assert_template 'show' - assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } + assert_select 'a[href=?]', '/projects/1/wiki/CookBook_documentation/edit', 0 end def test_show_pdf @@ -889,7 +846,7 @@ class WikiControllerTest < ActionController::TestCase assert_equal 'text/html', @response.content_type assert_equal 'attachment; filename="CookBook_documentation.html"', @response.headers['Content-Disposition'] - assert_tag 'h1', :content => 'CookBook documentation' + assert_select 'h1', :text => /CookBook documentation/ end def test_show_versioned_html @@ -901,7 +858,7 @@ class WikiControllerTest < ActionController::TestCase assert_equal 'text/html', @response.content_type assert_equal 'attachment; filename="CookBook_documentation.html"', @response.headers['Content-Disposition'] - assert_tag 'h1', :content => 'CookBook documentation' + assert_select 'h1', :text => /CookBook documentation/ end def test_show_txt diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb index 0d3af845a..10d68bf15 100644 --- a/test/functional/workflows_controller_test.rb +++ b/test/functional/workflows_controller_test.rb @@ -31,8 +31,7 @@ class WorkflowsControllerTest < ActionController::TestCase assert_template 'index' count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count - assert_tag :tag => 'a', :content => count.to_s, - :attributes => { :href => '/workflows/edit?role_id=1&tracker_id=2' } + assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s end def test_get_edit |