summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-22 09:38:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-22 09:38:21 +0000
commitf3e573b5f891c71f9395562a3f8747ecec801091 (patch)
tree7987fd3efa8ae985b532a03e7e0f529fa997258d /test
parent3602cd637c9ece4e0caa42c335acb7dce719a20e (diff)
downloadredmine-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')
-rw-r--r--test/functional/account_controller_test.rb2
-rw-r--r--test/functional/auth_sources_controller_test.rb4
-rw-r--r--test/functional/issue_statuses_controller_test.rb4
-rw-r--r--test/functional/issues_controller_test.rb20
-rw-r--r--test/functional/issues_controller_transaction_test.rb24
-rw-r--r--test/functional/messages_controller_test.rb9
-rw-r--r--test/functional/my_controller_test.rb6
-rw-r--r--test/functional/news_controller_test.rb8
-rw-r--r--test/functional/previews_controller_test.rb8
-rw-r--r--test/functional/projects_controller_test.rb2
-rw-r--r--test/functional/queries_controller_test.rb40
-rw-r--r--test/functional/repositories_bazaar_controller_test.rb13
-rw-r--r--test/functional/repositories_controller_test.rb49
-rw-r--r--test/functional/repositories_cvs_controller_test.rb33
-rw-r--r--test/functional/repositories_darcs_controller_test.rb8
-rw-r--r--test/functional/repositories_filesystem_controller_test.rb26
-rw-r--r--test/functional/repositories_git_controller_test.rb95
-rw-r--r--test/functional/repositories_mercurial_controller_test.rb69
-rw-r--r--test/functional/repositories_subversion_controller_test.rb36
-rw-r--r--test/functional/roles_controller_test.rb16
-rw-r--r--test/functional/search_controller_test.rb10
-rw-r--r--test/functional/settings_controller_test.rb8
-rw-r--r--test/functional/sys_controller_test.rb27
-rw-r--r--test/functional/time_entry_reports_controller_test.rb15
-rw-r--r--test/functional/timelog_controller_test.rb31
-rw-r--r--test/functional/trackers_controller_test.rb17
-rw-r--r--test/functional/users_controller_test.rb4
-rw-r--r--test/functional/versions_controller_test.rb2
-rw-r--r--test/functional/welcome_controller_test.rb4
-rw-r--r--test/functional/wiki_controller_test.rb171
-rw-r--r--test/functional/workflows_controller_test.rb3
-rw-r--r--test/integration/account_test.rb8
-rw-r--r--test/integration/api_test/attachments_test.rb19
-rw-r--r--test/integration/api_test/issue_categories_test.rb10
-rw-r--r--test/integration/api_test/issue_relations_test.rb16
-rw-r--r--test/integration/api_test/issue_statuses_test.rb16
-rw-r--r--test/integration/api_test/issues_test.rb202
-rw-r--r--test/integration/api_test/memberships_test.rb48
-rw-r--r--test/integration/api_test/news_test.rb20
-rw-r--r--test/integration/api_test/projects_test.rb71
-rw-r--r--test/integration/api_test/queries_test.rb16
-rw-r--r--test/integration/api_test/roles_test.rb16
-rw-r--r--test/integration/api_test/time_entries_test.rb13
-rw-r--r--test/integration/api_test/trackers_test.rb17
-rw-r--r--test/integration/api_test/users_test.rb34
-rw-r--r--test/integration/api_test/versions_test.rb23
-rw-r--r--test/integration/application_test.rb6
-rw-r--r--test/integration/issues_test.rb54
-rw-r--r--test/integration/layout_test.rb4
-rw-r--r--test/integration/lib/redmine/hook_test.rb3
-rw-r--r--test/integration/lib/redmine/menu_manager_test.rb30
-rw-r--r--test/test_helper.rb4
52 files changed, 443 insertions, 951 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&amp;tracker_id=2' }
+ assert_select 'a[href=?]', '/workflows/edit?role_id=1&amp;tracker_id=2', :content => count.to_s
end
def test_get_edit
diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb
index c822cc38a..8d8444a9d 100644
--- a/test/integration/account_test.rb
+++ b/test/integration/account_test.rb
@@ -229,10 +229,10 @@ class AccountTest < ActionDispatch::IntegrationTest
post '/login', :username => 'foo', :password => 'bar'
assert_response :success
assert_template 'account/register'
- assert_tag :input, :attributes => { :name => 'user[firstname]', :value => '' }
- assert_tag :input, :attributes => { :name => 'user[lastname]', :value => 'Smith' }
- assert_no_tag :input, :attributes => { :name => 'user[login]' }
- assert_no_tag :input, :attributes => { :name => 'user[password]' }
+ assert_select 'input[name=?][value=""]', 'user[firstname]'
+ assert_select 'input[name=?][value=Smith]', 'user[lastname]'
+ assert_select 'input[name=?]', 'user[login]', 0
+ assert_select 'input[name=?]', 'user[password]', 0
post 'account/register',
:user => {:firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com'}
diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb
index e1dc2cf89..5a80f5cc7 100644
--- a/test/integration/api_test/attachments_test.rb
+++ b/test/integration/api_test/attachments_test.rb
@@ -40,19 +40,10 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
get '/attachments/7.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'attachment',
- :child => {
- :tag => 'id',
- :content => '7',
- :sibling => {
- :tag => 'filename',
- :content => 'archive.zip',
- :sibling => {
- :tag => 'content_url',
- :content => 'http://www.example.com/attachments/download/7/archive.zip'
- }
- }
- }
+ assert_select 'attachment id:content(7)' do
+ assert_select '~ filename', :text => 'archive.zip'
+ assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/7/archive.zip'
+ end
end
test "GET /attachments/:id.xml should deny access without credentials" do
@@ -142,7 +133,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
assert_no_difference 'Attachment.count' do
post '/uploads.xml', ('x' * 2048), {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
assert_response 422
- assert_tag 'error', :content => /exceeds the maximum allowed file size/
+ assert_select 'error', :text => /exceeds the maximum allowed file size/
end
end
end
diff --git a/test/integration/api_test/issue_categories_test.rb b/test/integration/api_test/issue_categories_test.rb
index 2c1ea8a30..712cfb0d1 100644
--- a/test/integration/api_test/issue_categories_test.rb
+++ b/test/integration/api_test/issue_categories_test.rb
@@ -32,16 +32,14 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'issue_categories',
- :child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}}
+ assert_select 'issue_categories issue_category id', :text => '2'
end
test "GET /issue_categories/:id.xml should return the issue category" do
get '/issue_categories/2.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'issue_category',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'issue_category id', :text => '2'
end
test "POST /projects/:project_id/issue_categories.xml should return create issue category" do
@@ -63,7 +61,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "PUT /issue_categories/:id.xml with valid parameters should update the issue category" do
@@ -82,7 +80,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "DELETE /issue_categories/:id.xml should destroy the issue category" do
diff --git a/test/integration/api_test/issue_relations_test.rb b/test/integration/api_test/issue_relations_test.rb
index 5b9f11e8a..601e96067 100644
--- a/test/integration/api_test/issue_relations_test.rb
+++ b/test/integration/api_test/issue_relations_test.rb
@@ -37,15 +37,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'relations',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'relation',
- :child => {
- :tag => 'id',
- :content => '1'
- }
- }
+ assert_select 'relations[type=array] relation id', :text => '1'
end
test "POST /issues/:issue_id/relations.xml should create the relation" do
@@ -60,7 +52,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s}
+ assert_select 'relation id', :text => relation.id.to_s
end
test "POST /issues/:issue_id/relations.xml with failure should return errors" do
@@ -69,7 +61,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
end
assert_response :unprocessable_entity
- assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/}
+ assert_select 'errors error', :text => /relation_type is not included in the list/
end
test "GET /relations/:id.xml should return the relation" do
@@ -77,7 +69,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'relation', :child => {:tag => 'id', :content => '2'}
+ assert_select 'relation id', :text => '2'
end
test "DELETE /relations/:id.xml should delete the relation" do
diff --git a/test/integration/api_test/issue_statuses_test.rb b/test/integration/api_test/issue_statuses_test.rb
index 03b94c7d0..14a7f2d4d 100644
--- a/test/integration/api_test/issue_statuses_test.rb
+++ b/test/integration/api_test/issue_statuses_test.rb
@@ -29,18 +29,8 @@ class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'issue_statuses',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'issue_status',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => 'Assigned'
- }
- }
- }
+ assert_select 'issue_statuses[type=array] issue_status id:content(2)' do
+ assert_select '~ name', :text => 'Assigned'
+ end
end
end
diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb
index f6e458e99..d9525b963 100644
--- a/test/integration/api_test/issues_test.rb
+++ b/test/integration/api_test/issues_test.rb
@@ -56,13 +56,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "contain metadata" do
get '/issues.xml'
- assert_tag :tag => 'issues',
- :attributes => {
- :type => 'array',
- :total_count => assigns(:issue_count),
- :limit => 25,
- :offset => 0
- }
+ assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]', assigns(:issue_count).to_s
end
context "with offset and limit" do
@@ -71,7 +65,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_equal 3, assigns(:limit)
assert_equal 2, assigns(:offset)
- assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}}
+ assert_select 'issues issue', 3
end
end
@@ -79,13 +73,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "not contain metadata" do
get '/issues.xml?nometa=1'
- assert_tag :tag => 'issues',
- :attributes => {
- :type => 'array',
- :total_count => nil,
- :limit => nil,
- :offset => nil
- }
+ assert_select 'issues[type=array]:not([total_count]):not([limit]):not([offset])'
end
end
@@ -93,13 +81,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "not contain metadata" do
get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'}
- assert_tag :tag => 'issues',
- :attributes => {
- :type => 'array',
- :total_count => nil,
- :limit => nil,
- :offset => nil
- }
+ assert_select 'issues[type=array]:not([total_count]):not([limit]):not([offset])'
end
end
@@ -109,17 +91,16 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'relations',
- :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '3'}},
- :children => {:count => 1},
- :child => {
- :tag => 'relation',
- :attributes => {:id => '2', :issue_id => '2', :issue_to_id => '3',
- :relation_type => 'relates'}
- }
- assert_tag 'relations',
- :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}},
- :children => {:count => 0}
+
+ assert_select 'issue id:content(3)' do
+ assert_select '~ relations relation', 1
+ assert_select '~ relations relation[id="2"][issue_id="2"][issue_to_id="3"][relation_type=relates]'
+ end
+
+ assert_select 'issue id:content(1)' do
+ assert_select '~ relations'
+ assert_select '~ relations relation', 0
+ end
end
end
@@ -129,7 +110,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
+ assert_select 'errors error', :text => "Start date can't be blank"
end
end
@@ -233,31 +214,16 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display journals" do
get '/issues/1.xml?include=journals'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'journals',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'journal',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'details',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'detail',
- :attributes => { :name => 'status_id' },
- :child => {
- :tag => 'old_value',
- :content => '1',
- :sibling => {
- :tag => 'new_value',
- :content => '2'
- }
- }
- }
- }
- }
- }
+ assert_select 'issue journals[type=array]' do
+ assert_select 'journal[id="1"]' do
+ assert_select 'details[type=array]' do
+ assert_select 'detail[name=status_id]' do
+ assert_select 'old_value', :text => '1'
+ assert_select 'new_value', :text => '2'
+ end
+ end
+ end
+ end
end
end
end
@@ -267,19 +233,11 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display custom fields" do
get '/issues/3.xml'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'custom_fields',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'custom_field',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'value',
- :content => 'MySQL'
- }
- }
- }
+ assert_select 'issue custom_fields[type=array]' do
+ assert_select 'custom_field[id="1"]' do
+ assert_select 'value', :text => 'MySQL'
+ end
+ end
assert_nothing_raised do
Hash.from_xml(response.body).to_xml
@@ -301,20 +259,12 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display custom fields" do
get '/issues/3.xml'
assert_response :success
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'custom_fields',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'custom_field',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'value',
- :attributes => { :type => 'array' },
- :children => { :count => 2 }
- }
- }
- }
+
+ assert_select 'issue custom_fields[type=array]' do
+ assert_select 'custom_field[id="1"]' do
+ assert_select 'value[type=array] value', 2
+ end
+ end
xml = Hash.from_xml(response.body)
custom_fields = xml['issue']['custom_fields']
@@ -351,21 +301,12 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
context ".xml" do
should "display custom fields" do
get '/issues/3.xml'
- assert_response :success
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'custom_fields',
- :attributes => { :type => 'array' },
- :child => {
- :tag => 'custom_field',
- :attributes => { :id => '1'},
- :child => {
- :tag => 'value',
- :attributes => { :type => 'array' },
- :children => { :count => 0 }
- }
- }
- }
+
+ assert_select 'issue custom_fields[type=array]' do
+ assert_select 'custom_field[id="1"]' do
+ assert_select 'value[type=array]:empty'
+ end
+ end
xml = Hash.from_xml(response.body)
custom_fields = xml['issue']['custom_fields']
@@ -395,22 +336,13 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display attachments" do
get '/issues/3.xml?include=attachments'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'attachments',
- :children => {:count => 5},
- :child => {
- :tag => 'attachment',
- :child => {
- :tag => 'filename',
- :content => 'source.rb',
- :sibling => {
- :tag => 'content_url',
- :content => 'http://www.example.com/attachments/download/4/source.rb'
- }
- }
- }
- }
+ assert_select 'issue attachments[type=array]' do
+ assert_select 'attachment', 5
+ assert_select 'attachment id:content(4)' do
+ assert_select '~ filename', :text => 'source.rb'
+ assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/4/source.rb'
+ end
+ end
end
end
end
@@ -438,27 +370,15 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display children" do
get '/issues/1.xml?include=children'
- assert_tag :tag => 'issue',
- :child => {
- :tag => 'children',
- :children => {:count => 2},
- :child => {
- :tag => 'issue',
- :attributes => {:id => @c1.id.to_s},
- :child => {
- :tag => 'subject',
- :content => 'child c1',
- :sibling => {
- :tag => 'children',
- :children => {:count => 1},
- :child => {
- :tag => 'issue',
- :attributes => {:id => @c3.id.to_s}
- }
- }
- }
- }
- }
+ assert_select 'issue children[type=array]' do
+ assert_select 'issue', 2
+ assert_select 'issue[id=?]', @c1.id.to_s do
+ assert_select 'subject', :text => 'child c1'
+ assert_select 'children' do
+ assert_select 'issue[id=?]', @c3.id.to_s
+ end
+ end
+ end
end
context ".json" do
@@ -522,7 +442,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s}
+ assert_select 'issue > id', :text => issue.id.to_s
end
end
@@ -544,7 +464,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith')
end
- assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
+ assert_select 'errors error', :text => "Subject can't be blank"
end
end
@@ -698,7 +618,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "have an errors tag" do
put '/issues/6.xml', @parameters, credentials('jsmith')
- assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
+ assert_select 'errors error', :text => "Subject can't be blank"
end
end
diff --git a/test/integration/api_test/memberships_test.rb b/test/integration/api_test/memberships_test.rb
index 2493c797d..9f8ac24e8 100644
--- a/test/integration/api_test/memberships_test.rb
+++ b/test/integration/api_test/memberships_test.rb
@@ -29,26 +29,10 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'memberships',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'membership',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'user',
- :attributes => {:id => '3', :name => 'Dave Lopper'},
- :sibling => {
- :tag => 'roles',
- :child => {
- :tag => 'role',
- :attributes => {:id => '2', :name => 'Developer'}
- }
- }
- }
- }
- }
+ assert_select 'memberships[type=array] membership id:content(2)' do
+ assert_select '~ user[id=3][name=Dave Lopper]'
+ assert_select '~ roles role[id=2][name=Developer]'
+ end
end
test "GET /projects/:project_id/memberships.json should return memberships" do
@@ -105,7 +89,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Principal can't be blank"}
+ assert_select 'errors error', :text => "Principal can't be blank"
end
end
@@ -114,22 +98,10 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'membership',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'user',
- :attributes => {:id => '3', :name => 'Dave Lopper'},
- :sibling => {
- :tag => 'roles',
- :child => {
- :tag => 'role',
- :attributes => {:id => '2', :name => 'Developer'}
- }
- }
- }
- }
+ assert_select 'membership id:content(2)' do
+ assert_select '~ user[id=3][name=Dave Lopper]'
+ assert_select '~ roles role[id=2][name=Developer]'
+ end
end
test "GET /memberships/:id.json should return the membership" do
@@ -165,7 +137,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => /role can't be empty/i}
+ assert_select 'errors error', :text => "Role can't be empty"
end
test "DELETE /memberships/:id.xml should destroy the membership" do
diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb
index a60fe94c8..67984e70f 100644
--- a/test/integration/api_test/news_test.rb
+++ b/test/integration/api_test/news_test.rb
@@ -37,15 +37,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
test "GET /news.xml should return news" do
get '/news.xml'
- assert_tag :tag => 'news',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'news',
- :child => {
- :tag => 'id',
- :content => '2'
- }
- }
+ assert_select 'news[type=array] news id', :text => '2'
end
test "GET /news.json should return news" do
@@ -61,15 +53,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
test "GET /projects/:project_id/news.xml should return news" do
get '/projects/ecookbook/news.xml'
- assert_tag :tag => 'news',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'news',
- :child => {
- :tag => 'id',
- :content => '2'
- }
- }
+ assert_select 'news[type=array] news id', :text => '2'
end
test "GET /projects/:project_id/news.json should return news" do
diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb
index a345f5822..16c556dde 100644
--- a/test/integration/api_test/projects_test.rb
+++ b/test/integration/api_test/projects_test.rb
@@ -71,15 +71,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'issue_categories',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'issue_category',
- :attributes => {
- :id => '2',
- :name => 'Recipes'
- }
- }
+ assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
end
test "GET /projects.xml with include=trackers should return trackers" do
@@ -87,15 +79,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'trackers',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'tracker',
- :attributes => {
- :id => '2',
- :name => 'Feature request'
- }
- }
+ assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
end
test "GET /projects.xml with include=enabled_modules should return enabled modules" do
@@ -103,14 +87,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'enabled_modules',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'enabled_module',
- :attributes => {
- :name => 'issue_tracking'
- }
- }
+ assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "GET /projects/:id.xml should return the project" do
@@ -123,8 +100,8 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_select 'project>is_public', :text => 'true'
assert_select 'custom_field[name=Development status]', :text => 'Stable'
- assert_no_tag 'trackers'
- assert_no_tag 'issue_categories'
+ assert_select 'trackers', 0
+ assert_select 'issue_categories', 0
end
test "GET /projects/:id.json should return the project" do
@@ -143,8 +120,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_no_tag 'custom_field',
- :attributes => {:name => 'Development status'}
+ assert_select 'custom_field[name=?]', 'Development status', 0
end
test "GET /projects/:id.xml with include=issue_categories should return categories" do
@@ -152,15 +128,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'issue_categories',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'issue_category',
- :attributes => {
- :id => '2',
- :name => 'Recipes'
- }
- }
+ assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
end
test "GET /projects/:id.xml with include=trackers should return trackers" do
@@ -168,15 +136,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'trackers',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'tracker',
- :attributes => {
- :id => '2',
- :name => 'Feature request'
- }
- }
+ assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
end
test "GET /projects/:id.xml with include=enabled_modules should return enabled modules" do
@@ -184,14 +144,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag 'enabled_modules',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'enabled_module',
- :attributes => {
- :name => 'issue_tracking'
- }
- }
+ assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "POST /projects.xml with valid parameters should create the project" do
@@ -211,7 +164,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'project', :child => {:tag => 'id', :content => project.id.to_s}
+ assert_select 'project id', :text => project.id.to_s
end
test "POST /projects.xml should accept enabled_module_names attribute" do
@@ -243,7 +196,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Identifier can't be blank"}
+ assert_select 'errors error', :text => "Identifier can't be blank"
end
test "PUT /projects/:id.xml with valid parameters should update the project" do
@@ -284,7 +237,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "DELETE /projects/:id.xml should delete the project" do
diff --git a/test/integration/api_test/queries_test.rb b/test/integration/api_test/queries_test.rb
index afaed3090..72e9ed5e2 100644
--- a/test/integration/api_test/queries_test.rb
+++ b/test/integration/api_test/queries_test.rb
@@ -36,18 +36,8 @@ class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'queries',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'query',
- :child => {
- :tag => 'id',
- :content => '4',
- :sibling => {
- :tag => 'name',
- :content => 'Public query for all projects'
- }
- }
- }
+ assert_select 'queries[type=array] query id:content(4)' do
+ assert_select '~ name', :text => 'Public query for all projects'
+ end
end
end
diff --git a/test/integration/api_test/roles_test.rb b/test/integration/api_test/roles_test.rb
index 59dd12fbf..4f04b4b25 100644
--- a/test/integration/api_test/roles_test.rb
+++ b/test/integration/api_test/roles_test.rb
@@ -31,19 +31,9 @@ class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
assert_equal 'application/xml', @response.content_type
assert_equal 3, assigns(:roles).size
- assert_tag :tag => 'roles',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'role',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => 'Developer'
- }
- }
- }
+ assert_select 'roles[type=array] role id:content(2)' do
+ assert_select '~ name', :text => 'Developer'
+ end
end
test "GET /roles.json should return the roles" do
diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb
index 93c42e675..9fa93cd27 100644
--- a/test/integration/api_test/time_entries_test.rb
+++ b/test/integration/api_test/time_entries_test.rb
@@ -35,24 +35,21 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
get '/time_entries.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'time_entries',
- :child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}}
+ assert_select 'time_entries[type=array] time_entry id', :text => '2'
end
test "GET /time_entries.xml with limit should return limited results" do
get '/time_entries.xml?limit=2', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'time_entries',
- :children => {:count => 2}
+ assert_select 'time_entries[type=array] time_entry', 2
end
test "GET /time_entries/:id.xml should return the time entry" do
get '/time_entries/2.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'time_entry',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'time_entry id', :text => '2'
end
test "POST /time_entries.xml with issue_id should create time entry" do
@@ -109,7 +106,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Hours can't be blank"}
+ assert_select 'errors error', :text => "Hours can't be blank"
end
test "PUT /time_entries/:id.xml with valid parameters should update time entry" do
@@ -128,7 +125,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {:tag => 'error', :content => "Hours can't be blank"}
+ assert_select 'errors error', :text => "Hours can't be blank"
end
test "DELETE /time_entries/:id.xml should destroy time entry" do
diff --git a/test/integration/api_test/trackers_test.rb b/test/integration/api_test/trackers_test.rb
index 80188a3de..d85e2a4c3 100644
--- a/test/integration/api_test/trackers_test.rb
+++ b/test/integration/api_test/trackers_test.rb
@@ -29,18 +29,9 @@ class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'trackers',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'tracker',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => 'Feature request'
- }
- }
- }
+
+ assert_select 'trackers[type=array] tracker id:content(2)' do
+ assert_select '~ name', :text => 'Feature request'
+ end
end
end
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 2fab3f80c..f44948c54 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -67,8 +67,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
get '/users/2.xml'
assert_response :success
- assert_tag :tag => 'user',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'user id', :text => '2'
end
test "GET /users/:id.json should return the user" do
@@ -85,9 +84,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
get '/users/2.xml?include=memberships'
assert_response :success
- assert_tag :tag => 'memberships',
- :parent => {:tag => 'user'},
- :children => {:count => 1}
+ assert_select 'user memberships', 1
end
test "GET /users/:id.json with include=memberships should include memberships" do
@@ -112,44 +109,43 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "GET /users/current.xml should return current user" do
get '/users/current.xml', {}, credentials('jsmith')
- assert_tag :tag => 'user',
- :child => {:tag => 'id', :content => '2'}
+ assert_select 'user id', :text => '2'
end
test "GET /users/:id should not return login for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
- assert_no_tag 'user', :child => {:tag => 'login'}
+ assert_select 'user login', 0
end
test "GET /users/:id should return login for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
- assert_tag 'user', :child => {:tag => 'login', :content => 'jsmith'}
+ assert_select 'user login', :text => 'jsmith'
end
test "GET /users/:id should not return api_key for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
- assert_no_tag 'user', :child => {:tag => 'api_key'}
+ assert_select 'user api_key', 0
end
test "GET /users/:id should return api_key for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
- assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key}
+ assert_select 'user api_key', :text => User.find(2).api_key
end
test "GET /users/:id should not return status for standard user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
- assert_no_tag 'user', :child => {:tag => 'status'}
+ assert_select 'user status', 0
end
test "GET /users/:id should return status for administrators" do
get '/users/2.xml', {}, credentials('admin')
assert_response :success
- assert_tag 'user', :child => {:tag => 'status', :content => User.find(1).status.to_s}
+ assert_select 'user status', :text => User.find(1).status.to_s
end
test "POST /users.xml with valid parameters should create the user" do
@@ -174,7 +170,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'user', :child => {:tag => 'id', :content => user.id.to_s}
+ assert_select 'user id', :text => user.id.to_s
end
test "POST /users.json with valid parameters should create the user" do
@@ -210,10 +206,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {
- :tag => 'error',
- :content => "First name can't be blank"
- }
+ assert_select 'errors error', :text => "First name can't be blank"
end
test "POST /users.json with with invalid parameters should return errors" do
@@ -283,10 +276,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
- assert_tag 'errors', :child => {
- :tag => 'error',
- :content => "First name can't be blank"
- }
+ assert_select 'errors error', :text => "First name can't be blank"
end
test "PUT /users/:id.json with invalid parameters" do
diff --git a/test/integration/api_test/versions_test.rb b/test/integration/api_test/versions_test.rb
index 2e217d9b1..77fd2c0e5 100644
--- a/test/integration/api_test/versions_test.rb
+++ b/test/integration/api_test/versions_test.rb
@@ -36,19 +36,10 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
- assert_tag :tag => 'versions',
- :attributes => {:type => 'array'},
- :child => {
- :tag => 'version',
- :child => {
- :tag => 'id',
- :content => '2',
- :sibling => {
- :tag => 'name',
- :content => '1.0'
- }
- }
- }
+
+ assert_select 'versions[type=array] version id:content(2)' do
+ assert_select '~ name', :text => '1.0'
+ end
end
test "POST /projects/:project_id/versions.xml should create the version" do
@@ -61,7 +52,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
+ assert_select 'version id', :text => version.id.to_s
end
test "POST /projects/:project_id/versions.xml should create the version with due date" do
@@ -75,7 +66,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
- assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
+ assert_select 'version id', :text => version.id.to_s
end
test "POST /projects/:project_id/versions.xml should create the version with custom fields" do
@@ -107,7 +98,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
end
assert_response :unprocessable_entity
- assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
+ assert_select 'errors error', :text => "Name can't be blank"
end
test "GET /versions/:id.xml should return the version" do
diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb
index ced1783e5..e70277a2e 100644
--- a/test/integration/application_test.rb
+++ b/test/integration/application_test.rb
@@ -34,21 +34,21 @@ class ApplicationTest < ActionDispatch::IntegrationTest
# a french user
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Projets'
+ assert_select 'h2', :text => 'Projets'
assert_equal :fr, current_language
assert_select "html[lang=?]", "fr"
# then an italien user
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Progetti'
+ assert_select 'h2', :text => 'Progetti'
assert_equal :it, current_language
assert_select "html[lang=?]", "it"
# not a supported language: default language should be used
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Projects'
+ assert_select 'h2', :text => 'Projects'
assert_select "html[lang=?]", "en"
end
diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb
index 1e7efde7a..1f30acc8a 100644
--- a/test/integration/issues_test.rb
+++ b/test/integration/issues_test.rb
@@ -115,9 +115,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
get '/projects/ecookbook/issues'
%w(Atom PDF CSV).each do |format|
- assert_tag :a, :content => format,
- :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
- :rel => 'nofollow' }
+ assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
end
end
@@ -125,9 +123,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
get '/issues', :project_id => 'ecookbook'
%w(Atom PDF CSV).each do |format|
- assert_tag :a, :content => format,
- :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
- :rel => 'nofollow' }
+ assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
end
end
@@ -135,8 +131,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
with_settings :per_page_options => '2' do
get '/projects/ecookbook/issues'
- assert_tag :a, :content => '2',
- :attributes => { :href => '/projects/ecookbook/issues?page=2' }
+ assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
end
end
@@ -144,8 +139,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
with_settings :per_page_options => '2' do
get '/issues', :project_id => 'ecookbook'
- assert_tag :a, :content => '2',
- :attributes => { :href => '/projects/ecookbook/issues?page=2' }
+ assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
end
end
@@ -158,14 +152,10 @@ class IssuesTest < ActionDispatch::IntegrationTest
# Issue form
get '/projects/ecookbook/issues/new'
assert_response :success
- assert_tag :select,
- :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
- :children => {:count => (users.size + 1)}, # +1 for blank value
- :child => {
- :tag => 'option',
- :attributes => {:value => tester.id.to_s},
- :content => tester.name
- }
+ assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
+ assert_select 'option', users.size + 1 # +1 for blank value
+ assert_select 'option[value=?]', tester.id.to_s, :text => tester.name
+ end
# Create issue
assert_difference 'Issue.count' do
@@ -182,20 +172,11 @@ class IssuesTest < ActionDispatch::IntegrationTest
# Issue view
follow_redirect!
- assert_tag :th,
- :content => /Tester/,
- :sibling => {
- :tag => 'td',
- :content => tester.name
- }
- assert_tag :select,
- :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
- :children => {:count => (users.size + 1)}, # +1 for blank value
- :child => {
- :tag => 'option',
- :attributes => {:value => tester.id.to_s, :selected => 'selected'},
- :content => tester.name
- }
+ assert_select 'th:content(Tester:) + td', :text => tester.name
+ assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
+ assert_select 'option', users.size + 1 # +1 for blank value
+ assert_select 'option[value=?][selected=selected]', tester.id.to_s, :text => tester.name
+ end
# Update issue
new_tester = users[1]
@@ -210,14 +191,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
# Issue view
follow_redirect!
- assert_tag :content => 'Tester',
- :ancestor => {:tag => 'ul', :attributes => {:class => /details/}},
- :sibling => {
- :content => tester.name,
- :sibling => {
- :content => new_tester.name
- }
- }
+ assert_select 'ul.details li', :text => "Tester changed from #{tester} to #{new_tester}"
end
def test_update_using_invalid_http_verbs
diff --git a/test/integration/layout_test.rb b/test/integration/layout_test.rb
index 0e6fa24e8..fd9ddc28e 100644
--- a/test/integration/layout_test.rb
+++ b/test/integration/layout_test.rb
@@ -65,9 +65,7 @@ class LayoutTest < ActionDispatch::IntegrationTest
Role.anonymous.add_permission! :add_issues
get '/projects/ecookbook/issues/new'
- assert_tag :script,
- :attributes => {:src => %r{^/javascripts/jstoolbar/jstoolbar-textile.min.js}},
- :parent => {:tag => 'head'}
+ assert_select 'head script[src=?]', '/javascripts/jstoolbar/jstoolbar-textile.min.js'
end
def test_calendar_header_tags
diff --git a/test/integration/lib/redmine/hook_test.rb b/test/integration/lib/redmine/hook_test.rb
index f0520b58e..9e5c5bbb1 100644
--- a/test/integration/lib/redmine/hook_test.rb
+++ b/test/integration/lib/redmine/hook_test.rb
@@ -76,8 +76,7 @@ VIEW
Redmine::Hook.add_listener(ProjectBasedTemplate)
get '/projects/ecookbook'
- assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
- :parent => {:tag => 'head'}
+ assert_select 'head link[href=?]', '/stylesheets/ecookbook.css'
end
def test_empty_sidebar_should_be_hidden
diff --git a/test/integration/lib/redmine/menu_manager_test.rb b/test/integration/lib/redmine/menu_manager_test.rb
index 5d3826a23..bc4fbf017 100644
--- a/test/integration/lib/redmine/menu_manager_test.rb
+++ b/test/integration/lib/redmine/menu_manager_test.rb
@@ -31,14 +31,10 @@ class MenuManagerTest < ActionDispatch::IntegrationTest
def test_project_menu_with_specific_locale
get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity),
- :attributes => { :href => '/projects/ecookbook/activity',
- :class => 'activity' } } }
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural),
- :attributes => { :href => '/projects/ecookbook/issues',
- :class => 'issues selected' } } }
+ assert_select 'div#main-menu' do
+ assert_select 'li a.activity[href=?]', '/projects/ecookbook/activity', :text => ll('fr', :label_activity)
+ assert_select 'li a.issues.selected[href=?]', '/projects/ecookbook/issues', :text => ll('fr', :label_issue_plural)
+ end
end
def test_project_menu_with_additional_menu_items
@@ -51,19 +47,13 @@ class MenuManagerTest < ActionDispatch::IntegrationTest
end
get 'projects/ecookbook'
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
- :attributes => { :class => 'foo' } } }
-
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
- :attributes => { :class => 'bar' } },
- :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
- :attributes => { :class => 'hello' } },
- :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
+ assert_select 'div#main-menu ul' do
+ assert_select 'li:last-child a.foo[href=?]', '/projects/ecookbook', :text => 'Foo'
+ assert_select 'li:nth-child(2) a.bar[href=?]', '/projects/ecookbook', :text => 'Bar'
+ assert_select 'li:nth-child(3) a.hello[href=?]', '/projects/ecookbook', :text => 'ECOOKBOOK'
+ assert_select 'li:nth-child(4) a', :text => 'Activity'
+ end
# Remove the menu items
Redmine::MenuManager.map :project_menu do |menu|
diff --git a/test/test_helper.rb b/test/test_helper.rb
index a894a60ad..022d6af08 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -188,8 +188,8 @@ class ActiveSupport::TestCase
assert_equal true, saved, message
end
- def assert_error_tag(options={})
- assert_tag({:attributes => { :id => 'errorExplanation' }}.merge(options))
+ def assert_select_error(arg)
+ assert_select '#errorExplanation', :text => arg
end
def assert_include(expected, s, message=nil)