diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-17 17:02:55 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-17 17:02:55 +0000 |
commit | d85f73a30d48b3472346fb712106e6d5f4403278 (patch) | |
tree | 35d9205b3bf1da3c4e1cc9fc7699f798395d4702 /test | |
parent | 3ea8b706978b490fc54cde8e14dcde2a748dec1a (diff) | |
download | redmine-d85f73a30d48b3472346fb712106e6d5f4403278.tar.gz redmine-d85f73a30d48b3472346fb712106e6d5f4403278.zip |
Upgrade to Rails 4.2.0 (#14534).
git-svn-id: http://svn.redmine.org/redmine/trunk@13892 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
42 files changed, 170 insertions, 156 deletions
diff --git a/test/extra/redmine_pm/repository_git_test.rb b/test/extra/redmine_pm/repository_git_test_pm.rb index b77d6deb1..b77d6deb1 100644 --- a/test/extra/redmine_pm/repository_git_test.rb +++ b/test/extra/redmine_pm/repository_git_test_pm.rb diff --git a/test/extra/redmine_pm/repository_subversion_test.rb b/test/extra/redmine_pm/repository_subversion_test_pm.rb index 744d1c23f..744d1c23f 100644 --- a/test/extra/redmine_pm/repository_subversion_test.rb +++ b/test/extra/redmine_pm/repository_subversion_test_pm.rb diff --git a/test/functional/activities_controller_test.rb b/test/functional/activities_controller_test.rb index 78a0cc029..6a1d2a7db 100644 --- a/test/functional/activities_controller_test.rb +++ b/test/functional/activities_controller_test.rb @@ -118,8 +118,8 @@ class ActivitiesControllerTest < ActionController::TestCase assert_template 'common/feed' assert_select 'feed' do - assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0' - assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0' + assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0' + assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0' assert_select 'entry' do assert_select 'link[href=?]', 'http://test.host/issues/11' end diff --git a/test/functional/auth_sources_controller_test.rb b/test/functional/auth_sources_controller_test.rb index 1a396ba1c..7e15ee8a3 100644 --- a/test/functional/auth_sources_controller_test.rb +++ b/test/functional/auth_sources_controller_test.rb @@ -94,7 +94,7 @@ class AuthSourcesControllerTest < ActionController::TestCase get :edit, :id => 1 assert_response :success assert_select 'input[value=secret]', 0 - assert_select 'input[name=dummy_password][value=?]', /x+/ + assert_select 'input[name=dummy_password][value^=xxxxxx]' end def test_edit_invalid_should_respond_with_404 diff --git a/test/functional/boards_controller_test.rb b/test/functional/boards_controller_test.rb index 9563b26d5..c585760af 100644 --- a/test/functional/boards_controller_test.rb +++ b/test/functional/boards_controller_test.rb @@ -117,9 +117,13 @@ class BoardsControllerTest < ActionController::TestCase assert_select 'select[name=?]', 'board[parent_id]' do assert_select 'option', (Project.find(1).boards.size + 1) - assert_select 'option[value=""]', :text => ' ' + assert_select 'option[value=""]' assert_select 'option[value="1"]', :text => 'Help' end + + # replaced by nokogiri, not easy to test in DOM assertions + assert_not_include '<option value=""></option>', response.body + assert_include '<option value=""> </option>', response.body end def test_new_without_project_boards diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb index fadc7a1c8..0ecbf63da 100644 --- a/test/functional/context_menus_controller_test.rb +++ b/test/functional/context_menus_controller_test.rb @@ -44,15 +44,15 @@ class ContextMenusControllerTest < ActionController::TestCase assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete' # Statuses - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed' - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bstatus_id%5D=5', :text => 'Closed' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bpriority_id%5D=8', :text => 'Immediate' # No inactive priorities assert_select 'a', :text => /Inactive Priority/, :count => 0 # Versions - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0' - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=3', :text => '2.0' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bfixed_version_id%5D=4', :text => 'eCookbook Subproject 1 - 2.0' # Assignees - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=3', :text => 'Dave Lopper' end def test_context_menu_one_issue_by_anonymous @@ -72,15 +72,15 @@ class ContextMenusControllerTest < ActionController::TestCase assert_not_nil assigns(:issues) assert_equal [1, 2], assigns(:issues).map(&:id).sort - ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&') + ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&') assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' - assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy' + assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy' assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete' - assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed' - assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate' - assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=3", :text => 'Dave Lopper' + assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed' + assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate' + assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=3", :text => 'Dave Lopper' end def test_context_menu_multiple_issues_of_different_projects @@ -91,14 +91,14 @@ class ContextMenusControllerTest < ActionController::TestCase assert_not_nil assigns(:issues) assert_equal [1, 2, 6], assigns(:issues).map(&:id).sort - ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&') + ids = assigns(:issues).map(&:id).sort.map {|i| "ids%5B%5D=#{i}"}.join('&') assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit' assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete' - assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed' - assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate' - assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=2", :text => 'John Smith' + assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed' + assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bpriority_id%5D=8", :text => 'Immediate' + assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bassigned_to_id%5D=2", :text => 'John Smith' end def test_context_menu_should_include_list_custom_fields @@ -108,11 +108,11 @@ class ContextMenusControllerTest < ActionController::TestCase get :issues, :ids => [1] assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => 'List' + assert_select 'a[href="#"]', :text => 'List' assert_select 'ul' do assert_select 'a', 3 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=Foo", :text => 'Foo' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -124,7 +124,7 @@ class ContextMenusControllerTest < ActionController::TestCase get :issues, :ids => [1, 2] assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => 'List' + assert_select 'a[href="#"]', :text => 'List' assert_select 'ul' do assert_select 'a', 2 assert_select 'a', :text => 'none', :count => 0 @@ -142,7 +142,7 @@ class ContextMenusControllerTest < ActionController::TestCase get :issues, :ids => [1] assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => 'List' + assert_select 'a[href="#"]', :text => 'List' assert_select 'ul' do assert_select 'a', 3 assert_select 'a.icon-checked', :text => 'Bar' @@ -157,12 +157,12 @@ class ContextMenusControllerTest < ActionController::TestCase get :issues, :ids => [1] assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => 'Bool' + assert_select 'a[href="#"]', :text => 'Bool' assert_select 'ul' do assert_select 'a', 3 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=0", :text => 'No' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=1", :text => 'Yes' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -174,11 +174,11 @@ class ContextMenusControllerTest < ActionController::TestCase get :issues, :ids => [1] assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => 'User' + assert_select 'a[href="#"]', :text => 'User' assert_select 'ul' do assert_select 'a', Project.find(1).members.count + 1 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=2", :text => 'John Smith' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -189,11 +189,11 @@ class ContextMenusControllerTest < ActionController::TestCase get :issues, :ids => [1] assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => 'Version' + assert_select 'a[href="#"]', :text => 'Version' assert_select 'ul' do assert_select 'a', Project.find(1).shared_versions.count + 1 - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0' - assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=3", :text => '2.0' + assert_select 'a[href=?]', "/issues/bulk_update?ids%5B%5D=1&issue%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end @@ -216,7 +216,7 @@ class ContextMenusControllerTest < ActionController::TestCase assert_response :success assert_template 'context_menus/issues' - assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / + assert_select 'a[href=?]', '/issues/bulk_update?ids%5B%5D=1&issue%5Bassigned_to_id%5D=2', :text => / me / end def test_context_menu_should_propose_shared_versions_for_issues_from_different_projects @@ -266,12 +266,12 @@ class ContextMenusControllerTest < ActionController::TestCase get :time_entries, :ids => [1, 2] assert_response :success assert_select "li.cf_#{field.id}" do - assert_select 'a[href=#]', :text => "Field" + assert_select 'a[href="#"]', :text => "Field" assert_select 'ul' do assert_select 'a', 3 - assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=foo", :text => 'foo' - assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=bar", :text => 'bar' - assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' + assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=foo", :text => 'foo' + assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=bar", :text => 'bar' + assert_select 'a[href=?]', "/time_entries/bulk_update?ids%5B%5D=1&ids%5B%5D=2&time_entry%5Bcustom_field_values%5D%5B#{field.id}%5D=__none__", :text => 'none' end end end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 86c5cdb16..ac1cb2ffa 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -371,7 +371,7 @@ class IssuesControllerTest < ActionController::TestCase assert_select 'a.atom[href="/issues.atom"]' assert_select 'a.csv[href="/issues.csv"]' assert_select 'a.pdf[href="/issues.pdf"]' - assert_select 'form#csv-export-form[action=/issues.csv]' + assert_select 'form#csv-export-form[action="/issues.csv"]' end def test_index_should_not_warn_when_not_exceeding_export_limit @@ -861,7 +861,7 @@ class IssuesControllerTest < ActionController::TestCase get :index, :set_filter => 1, :c => %w(subject description) assert_select 'table.issues thead th', 3 # columns: chekbox + id + subject - assert_select 'td.description[colspan=3]', :text => 'Unable to print recipes' + assert_select 'td.description[colspan="3"]', :text => 'Unable to print recipes' get :index, :set_filter => 1, :c => %w(subject description), :format => 'pdf' assert_response :success @@ -1012,7 +1012,7 @@ class IssuesControllerTest < ActionController::TestCase @request.session[:user_id] = 2 get :show, :id => 1 - assert_select 'form#issue-form[method=post][enctype=multipart/form-data]' do + assert_select 'form#issue-form[method=post][enctype="multipart/form-data"]' do assert_select 'input[type=file][name=?]', 'attachments[dummy][file]' end end @@ -1622,7 +1622,7 @@ class IssuesControllerTest < ActionController::TestCase @request.session[:user_id] = 2 get :new, :project_id => 1, :tracker_id => 1 - assert_select 'form[id=issue-form][method=post][enctype=multipart/form-data]' do + assert_select 'form[id=issue-form][method=post][enctype="multipart/form-data"]' do assert_select 'input[name=?][type=file]', 'attachments[dummy][file]' end end @@ -2429,7 +2429,7 @@ class IssuesControllerTest < ActionController::TestCase assert_equal orig.subject, assigns(:issue).subject assert assigns(:issue).copy? - assert_select 'form[id=issue-form][action=/projects/ecookbook/issues]' do + assert_select 'form[id=issue-form][action="/projects/ecookbook/issues"]' do assert_select 'select[name=?]', 'issue[project_id]' do assert_select 'option[value="1"][selected=selected]', :text => 'eCookbook' assert_select 'option[value="2"]:not([selected])', :text => 'OnlineStore' @@ -2629,7 +2629,7 @@ class IssuesControllerTest < ActionController::TestCase assert_not_nil assigns(:issue) assert assigns(:issue).copy? - assert_select 'form#issue-form[action=/projects/ecookbook/issues]' do + assert_select 'form#issue-form[action="/projects/ecookbook/issues"]' do assert_select 'select[name=?]', 'issue[project_id]' do assert_select 'option[value="1"]:not([selected])', :text => 'eCookbook' assert_select 'option[value="2"][selected=selected]', :text => 'OnlineStore' @@ -2701,7 +2701,7 @@ class IssuesControllerTest < ActionController::TestCase assert_select 'option[value="7"][selected=selected]', :text => 'Urgent' end - assert_select 'input[name=?][value=2.5]', 'time_entry[hours]' + assert_select 'input[name=?][value="2.5"]', 'time_entry[hours]' assert_select 'select[name=?]', 'time_entry[activity_id]' do assert_select 'option[value="10"][selected=selected]', :text => 'Development' end diff --git a/test/functional/issues_controller_transaction_test.rb b/test/functional/issues_controller_transaction_test.rb index adbe17873..b38b09641 100644 --- a/test/functional/issues_controller_transaction_test.rb +++ b/test/functional/issues_controller_transaction_test.rb @@ -245,7 +245,7 @@ class IssuesControllerTransactionTest < ActionController::TestCase assert_select 'input[name=?][value=?]', 'time_entry[hours]', '2.5' assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'should not be added' assert_select 'select[name=?]', 'time_entry[activity_id]' do - assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id + assert_select 'option[value=?][selected=selected]', TimeEntryActivity.first.id.to_s end end diff --git a/test/functional/issues_custom_fields_visibility_test.rb b/test/functional/issues_custom_fields_visibility_test.rb index 6e9ec5f11..e23cd4fc2 100644 --- a/test/functional/issues_custom_fields_visibility_test.rb +++ b/test/functional/issues_custom_fields_visibility_test.rb @@ -83,9 +83,9 @@ class IssuesCustomFieldsVisibilityTest < ActionController::TestCase end @fields.each_with_index do |field, i| if fields.include?(field) - assert_select "custom_field[id=#{field.id}] value", {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} in API" + assert_select "custom_field[id=?] value", field.id.to_s, {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} in API" else - assert_select "custom_field[id=#{field.id}] value", {:text => "Value#{i}", :count => 0}, "User #{user.id} was not able to view #{field.name} in API" + assert_select "custom_field[id=?] value", field.id.to_s, {:text => "Value#{i}", :count => 0}, "User #{user.id} was not able to view #{field.name} in API" end end end diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index 5f14c5791..65190e611 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -126,7 +126,7 @@ class MyControllerTest < ActionController::TestCase get :destroy assert_response :success assert_template 'destroy' - assert_select 'form[action=/my/account/destroy]' do + assert_select 'form[action="/my/account/destroy"]' do assert_select 'input[name=confirm]' end end diff --git a/test/functional/repositories_bazaar_controller_test.rb b/test/functional/repositories_bazaar_controller_test.rb index cde2d1cf7..29b5bf77d 100644 --- a/test/functional/repositories_bazaar_controller_test.rb +++ b/test/functional/repositories_bazaar_controller_test.rb @@ -123,7 +123,7 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 11 removed - assert_select 'th.line-num:content(11) ~ td.diff_out', :text => /Display more information/ + assert_select 'th.line-num:contains(11) ~ td.diff_out', :text => /Display more information/ end end @@ -157,7 +157,7 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase assert_select "th.line-num", :text => '1' do assert_select "+ td.revision" do assert_select "a", :text => '2' - assert_select "+ td.author", :text => "test &" do + assert_select "+ td.author", :text => "test &" do assert_select "+ td", :text => "author escaping test" end diff --git a/test/functional/repositories_controller_test.rb b/test/functional/repositories_controller_test.rb index 14f6a6355..3e0fa5963 100644 --- a/test/functional/repositories_controller_test.rb +++ b/test/functional/repositories_controller_test.rb @@ -275,14 +275,8 @@ class RepositoriesControllerTest < ActionController::TestCase assert_response :success assert_template 'committers' - 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 + assert_select 'input[value=dlopper] + select option[value="3"][selected=selected]', :text => 'Dave Lopper' + assert_select 'input[value=foo] + select option[selected=selected]', 0 # no option selected end def test_post_committers diff --git a/test/functional/repositories_darcs_controller_test.rb b/test/functional/repositories_darcs_controller_test.rb index 9df8b2a24..7ff63a54b 100644 --- a/test/functional/repositories_darcs_controller_test.rb +++ b/test/functional/repositories_darcs_controller_test.rb @@ -116,7 +116,7 @@ class RepositoriesDarcsControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 22 removed - assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ end end diff --git a/test/functional/repositories_git_controller_test.rb b/test/functional/repositories_git_controller_test.rb index c6d7ada9b..0c55b571d 100644 --- a/test/functional/repositories_git_controller_test.rb +++ b/test/functional/repositories_git_controller_test.rb @@ -265,7 +265,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 22 removed - assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ assert_select 'h2', :text => /2f9c0091/ end end @@ -286,7 +286,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase assert_response :success assert_template 'diff' # Line 22 removed - assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ assert_select 'h2', :text => /2f9c0091/ end end diff --git a/test/functional/repositories_mercurial_controller_test.rb b/test/functional/repositories_mercurial_controller_test.rb index 734fe0e23..eb6440938 100644 --- a/test/functional/repositories_mercurial_controller_test.rb +++ b/test/functional/repositories_mercurial_controller_test.rb @@ -293,7 +293,7 @@ class RepositoriesMercurialControllerTest < ActionController::TestCase assert_template 'diff' if @diff_c_support # Line 22 removed - assert_select 'th.line-num:content(22) ~ td.diff_out', :text => /def remove/ + assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/ assert_select 'h2', :text => /4:def6d2f1254a/ end end diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 9372e40d2..10f6b02ae 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -315,8 +315,8 @@ class SearchControllerTest < ActionController::TestCase get :index, :q => 'escaped_once' assert_response :success assert_select '#search-results' do - assert_select 'dt.issue a', :text => /<subject>/ - assert_select 'dd', :text => /<description>/ + assert_select 'dt.issue a', :text => /<subject>/ + assert_select 'dd', :text => /<description>/ end end diff --git a/test/functional/settings_controller_test.rb b/test/functional/settings_controller_test.rb index 1df23ef54..de5fddd8a 100644 --- a/test/functional/settings_controller_test.rb +++ b/test/functional/settings_controller_test.rb @@ -139,9 +139,9 @@ class SettingsControllerTest < ActionController::TestCase def test_get_plugin_settings ActionController::Base.append_view_path(File.join(Rails.root, "test/fixtures/plugins")) Redmine::Plugin.register :foo do - settings :partial => "foo_plugin/foo_plugin_settings", - :default => {'sample_setting' => 'Plugin setting value'} + settings :partial => "foo_plugin/foo_plugin_settings" end + Setting.plugin_foo = {'sample_setting' => 'Plugin setting value'} get :plugin, :id => 'foo' assert_response :success diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index 003257d30..5f73e5874 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -667,7 +667,7 @@ class TimelogControllerTest < ActionController::TestCase assert_select 'form[action=?][method=get]', '/projects/ecookbook/time_entries.csv' do # filter assert_select 'input[name=?][value=?]', 'f[]', 'spent_on' - assert_select 'input[name=?][value=?]', 'op[spent_on]', '>=' + assert_select 'input[name=?][value=?]', 'op[spent_on]', '>=' assert_select 'input[name=?][value=?]', 'v[spent_on][]', '2007-04-01' # columns assert_select 'input[name=?][value=?]', 'c[]', 'spent_on' diff --git a/test/functional/welcome_controller_test.rb b/test/functional/welcome_controller_test.rb index c8502425f..a264201b6 100644 --- a/test/functional/welcome_controller_test.rb +++ b/test/functional/welcome_controller_test.rb @@ -127,7 +127,7 @@ class WelcomeControllerTest < ActionController::TestCase get :index assert_select "#header select" do - assert_select "option", :text => 'Foo & Bar' + assert_select "option", :text => 'Foo & Bar' end end diff --git a/test/functional/workflows_controller_test.rb b/test/functional/workflows_controller_test.rb index 26d5f7734..85e0a1cf5 100644 --- a/test/functional/workflows_controller_test.rb +++ b/test/functional/workflows_controller_test.rb @@ -31,7 +31,7 @@ class WorkflowsControllerTest < ActionController::TestCase assert_template 'index' count = WorkflowTransition.where(:role_id => 1, :tracker_id => 2).count - assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s + assert_select 'a[href=?]', '/workflows/edit?role_id=1&tracker_id=2', :content => count.to_s end def test_get_edit diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb index 06a926a31..d4b483527 100644 --- a/test/integration/api_test/attachments_test.rb +++ b/test/integration/api_test/attachments_test.rb @@ -41,7 +41,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base get '/attachments/7.xml', {}, credentials('jsmith') assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'attachment id:content(7)' do + assert_select 'attachment id', :text => '7' do assert_select '~ filename', :text => 'archive.zip' assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/7/archive.zip' end @@ -51,7 +51,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base get '/attachments/16.xml', {}, credentials('jsmith') assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'attachment id:content(16)' do + assert_select 'attachment id:contains(16)' do assert_select '~ thumbnail_url', :text => 'http://www.example.com/attachments/thumbnail/16' end end diff --git a/test/integration/api_test/groups_test.rb b/test/integration/api_test/groups_test.rb index 3c8ff9e6e..0a9373513 100644 --- a/test/integration/api_test/groups_test.rb +++ b/test/integration/api_test/groups_test.rb @@ -105,7 +105,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base assert_select 'group' do assert_select 'users' do assert_select 'user', Group.find(10).users.count - assert_select 'user[id=8]' + assert_select 'user[id="8"]' end end end diff --git a/test/integration/api_test/issue_statuses_test.rb b/test/integration/api_test/issue_statuses_test.rb index 5c72e48e4..d5c9994be 100644 --- a/test/integration/api_test/issue_statuses_test.rb +++ b/test/integration/api_test/issue_statuses_test.rb @@ -25,7 +25,7 @@ class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'issue_statuses[type=array] issue_status id:content(2)' do + assert_select 'issue_statuses[type=array] issue_status id', :text => '2' do assert_select '~ name', :text => 'Assigned' end end diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 4957ff5bb..747ade2f4 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -74,12 +74,12 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'issue id:content(3)' do + assert_select 'issue id', :text => '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 'issue id', :text => '1' do assert_select '~ relations' assert_select '~ relations relation', 0 end @@ -281,7 +281,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base assert_select 'issue attachments[type=array]' do assert_select 'attachment', 5 - assert_select 'attachment id:content(4)' do + assert_select 'attachment id', :text => '4' do assert_select '~ filename', :text => 'source.rb' assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/4/source.rb' end @@ -292,9 +292,9 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base issue = Issue.generate_with_descendants!(:project_id => 1) get "/issues/#{issue.id}.xml?include=children" - assert_select 'issue children[type=array]' do - assert_select 'issue', 2 - assert_select 'issue children', 1 + assert_select 'issue id', :text => issue.id.to_s do + assert_select '~ children[type=array] > issue', 2 + assert_select '~ children[type=array] > issue > children', 1 end end @@ -322,7 +322,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base assert_select 'issue' do assert_select 'watchers', Issue.find(1).watchers.count assert_select 'watchers' do - assert_select 'user[id=3]' + assert_select 'user[id="3"]' end end end diff --git a/test/integration/api_test/memberships_test.rb b/test/integration/api_test/memberships_test.rb index 513c5a922..7ee82fc7f 100644 --- a/test/integration/api_test/memberships_test.rb +++ b/test/integration/api_test/memberships_test.rb @@ -25,9 +25,9 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - 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]' + assert_select 'memberships[type=array] membership id', :text => '2' do + assert_select '~ user[id="3"][name="Dave Lopper"]' + assert_select '~ roles role[id="2"][name=Developer]' end end @@ -94,9 +94,9 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'membership id:content(2)' do - assert_select '~ user[id=3][name=Dave Lopper]' - assert_select '~ roles role[id=2][name=Developer]' + assert_select 'membership id', :text => '2' do + assert_select '~ user[id="3"][name="Dave Lopper"]' + assert_select '~ roles role[id="2"][name=Developer]' end end diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb index 9140965b3..b532f5a54 100644 --- a/test/integration/api_test/projects_test.rb +++ b/test/integration/api_test/projects_test.rb @@ -54,7 +54,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'issue_categories[type=array] issue_category[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 @@ -62,7 +62,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'trackers[type=array] tracker[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 @@ -81,7 +81,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base assert_select 'project>id', :text => '1' assert_select 'project>status', :text => '1' assert_select 'project>is_public', :text => 'true' - assert_select 'custom_field[name=Development status]', :text => 'Stable' + assert_select 'custom_field[name="Development status"]', :text => 'Stable' assert_select 'trackers', 0 assert_select 'issue_categories', 0 @@ -111,7 +111,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'issue_categories[type=array] issue_category[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 @@ -119,7 +119,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'trackers[type=array] tracker[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 diff --git a/test/integration/api_test/queries_test.rb b/test/integration/api_test/queries_test.rb index 5ce772fb7..2ba8e567b 100644 --- a/test/integration/api_test/queries_test.rb +++ b/test/integration/api_test/queries_test.rb @@ -32,7 +32,7 @@ class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'queries[type=array] query id:content(4)' do + assert_select 'queries[type=array] query id', :text => '4' do assert_select '~ name', :text => 'Public query for all projects' end end diff --git a/test/integration/api_test/roles_test.rb b/test/integration/api_test/roles_test.rb index 0c16826cb..0df9206fa 100644 --- a/test/integration/api_test/roles_test.rb +++ b/test/integration/api_test/roles_test.rb @@ -27,7 +27,7 @@ class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base assert_equal 'application/xml', @response.content_type assert_equal 3, assigns(:roles).size - assert_select 'roles[type=array] role id:content(2)' do + assert_select 'roles[type=array] role id', :text => '2' do assert_select '~ name', :text => 'Developer' end end diff --git a/test/integration/api_test/trackers_test.rb b/test/integration/api_test/trackers_test.rb index f5b2178cd..beabc4637 100644 --- a/test/integration/api_test/trackers_test.rb +++ b/test/integration/api_test/trackers_test.rb @@ -26,7 +26,7 @@ class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'trackers[type=array] tracker id:content(2)' do + assert_select 'trackers[type=array] tracker id', :text => '2' do assert_select '~ name', :text => 'Feature request' end end diff --git a/test/integration/api_test/versions_test.rb b/test/integration/api_test/versions_test.rb index 65b8a2ef5..0202d6c30 100644 --- a/test/integration/api_test/versions_test.rb +++ b/test/integration/api_test/versions_test.rb @@ -33,7 +33,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base assert_response :success assert_equal 'application/xml', @response.content_type - assert_select 'versions[type=array] version id:content(2)' do + assert_select 'versions[type=array] version id', :text => '2' do assert_select '~ name', :text => '1.0' end end diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 981fdb760..06d44824b 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -172,7 +172,7 @@ class IssuesTest < Redmine::IntegrationTest # Issue view follow_redirect! - assert_select 'th:content(Tester:) + td', :text => tester.name + assert_select 'th:contains("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 diff --git a/test/integration/layout_test.rb b/test/integration/layout_test.rb index 479b67753..2afd0b522 100644 --- a/test/integration/layout_test.rb +++ b/test/integration/layout_test.rb @@ -105,11 +105,11 @@ class LayoutTest < Redmine::IntegrationTest def test_search_field_outside_project_should_link_to_global_search get '/' - assert_select 'div#quick-search form[action=/search]' + assert_select 'div#quick-search form[action="/search"]' end def test_search_field_inside_project_should_link_to_project_search get '/projects/ecookbook' - assert_select 'div#quick-search form[action=/projects/ecookbook/search]' + assert_select 'div#quick-search form[action="/projects/ecookbook/search"]' end end diff --git a/test/integration/lib/redmine/themes_test.rb b/test/integration/lib/redmine/themes_test.rb index f38f722ca..66cfea208 100644 --- a/test/integration/lib/redmine/themes_test.rb +++ b/test/integration/lib/redmine/themes_test.rb @@ -20,6 +20,7 @@ require File.expand_path('../../../../test_helper', __FILE__) class ThemesTest < Redmine::IntegrationTest def setup + Redmine::Themes.rescan @theme = Redmine::Themes.themes.last Setting.ui_theme = @theme.id end @@ -32,14 +33,14 @@ class ThemesTest < Redmine::IntegrationTest get '/' assert_response :success - assert_select "link[rel=stylesheet][href^=/themes/#{@theme.dir}/stylesheets/application.css]" + assert_select "link[rel=stylesheet][href^=?]", "/themes/#{@theme.dir}/stylesheets/application.css" end def test_without_theme_js get '/' assert_response :success - assert_select "script[src^=/themes/#{@theme.dir}/javascripts/theme.js]", 0 + assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 0 end def test_with_theme_js @@ -48,7 +49,7 @@ class ThemesTest < Redmine::IntegrationTest get '/' assert_response :success - assert_select "script[src^=/themes/#{@theme.dir}/javascripts/theme.js]", 1 + assert_select "script[src^=?]", "/themes/#{@theme.dir}/javascripts/theme.js", 1 ensure @theme.javascripts.delete 'theme' end @@ -57,7 +58,7 @@ class ThemesTest < Redmine::IntegrationTest get '/' assert_response :success - assert_select 'link[rel=shortcut icon][href^=/favicon.ico]' + assert_select 'link[rel="shortcut icon"][href^="/favicon.ico"]' end def test_use_theme_favicon_if_theme_provides_one @@ -66,7 +67,7 @@ class ThemesTest < Redmine::IntegrationTest get '/' assert_response :success - assert_select "link[rel=shortcut icon][href^=/themes/#{@theme.dir}/favicon/a.ico]" + assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/a.ico" ensure @theme.favicons.delete 'a.ico' end @@ -76,8 +77,8 @@ class ThemesTest < Redmine::IntegrationTest get '/' assert_response :success - assert_select "link[rel=shortcut icon]", 1 - assert_select "link[rel=shortcut icon][href^=/themes/#{@theme.dir}/favicon/b.ico]" + assert_select 'link[rel="shortcut icon"]', 1 + assert_select 'link[rel="shortcut icon"][href^=?]', "/themes/#{@theme.dir}/favicon/b.ico" ensure @theme.favicons.delete("b.ico") @theme.favicons.delete("a.png") @@ -90,9 +91,9 @@ class ThemesTest < Redmine::IntegrationTest get '/' assert_response :success - assert_select "link[rel=stylesheet][href^=/foo/themes/#{@theme.dir}/stylesheets/application.css]" - assert_select "script[src^=/foo/themes/#{@theme.dir}/javascripts/theme.js]" - assert_select "link[rel=shortcut icon][href^=/foo/themes/#{@theme.dir}/favicon/a.ico]" + assert_select "link[rel=stylesheet][href^=?]", "/foo/themes/#{@theme.dir}/stylesheets/application.css" + assert_select "script[src^=?]", "/foo/themes/#{@theme.dir}/javascripts/theme.js" + assert_select 'link[rel="shortcut icon"][href^=?]', "/foo/themes/#{@theme.dir}/favicon/a.ico" ensure Redmine::Utils.relative_url_root = '' end diff --git a/test/test_helper.rb b/test/test_helper.rb index 6d6cf6dc8..1762de868 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -31,6 +31,7 @@ require File.expand_path(File.dirname(__FILE__) + '/object_helpers') include ObjectHelpers require 'net/ldap' +require 'mocha/setup' class ActionView::TestCase helper :application @@ -189,10 +190,18 @@ class ActiveSupport::TestCase end def assert_select_in(text, *args, &block) - d = HTML::Document.new(CGI::unescapeHTML(String.new(text))).root + d = Nokogiri::HTML(CGI::unescapeHTML(String.new(text))).root assert_select(d, *args, &block) end + def assert_select_email(*args, &block) + email = ActionMailer::Base.deliveries.last + assert_not_nil email + html_body = email.parts.detect {|part| part.content_type.include?('text/html')}.try(&:body) + assert_not_nil html_body + assert_select_in html_body.encoded, *args, &block + end + def assert_mail_body_match(expected, mail, message=nil) if expected.is_a?(String) assert_include expected, mail_body(mail), message diff --git a/test/ui/issues_test.rb b/test/ui/issues_test_ui.rb index dec6565d9..dec6565d9 100644 --- a/test/ui/issues_test.rb +++ b/test/ui/issues_test_ui.rb diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index 7512f1fe5..1ed964d5e 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -1217,15 +1217,15 @@ RAW result = textilizable(raw, :edit_section_links => {:controller => 'wiki', :action => 'edit', :project_id => '1', :id => 'Test'}).gsub("\n", "") # heading that contains inline code - assert_match Regexp.new('<div class="contextual" id="section-4" title="Edit this section">' + - '<a href="/projects/1/wiki/Test/edit\?section=4"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' + + assert_match Regexp.new('<div class="contextual" title="Edit this section" id="section-4">' + + '<a href="/projects/1/wiki/Test/edit\?section=4"><img src="/images/edit.png(\?\d+)?" alt="Edit" /></a></div>' + '<a name="Subtitle-with-inline-code"></a>' + '<h2 >Subtitle with <code>inline code</code><a href="#Subtitle-with-inline-code" class="wiki-anchor">¶</a></h2>'), result # last heading - assert_match Regexp.new('<div class="contextual" id="section-5" title="Edit this section">' + - '<a href="/projects/1/wiki/Test/edit\?section=5"><img alt="Edit" src="/images/edit.png(\?\d+)?" /></a></div>' + + assert_match Regexp.new('<div class="contextual" title="Edit this section" id="section-5">' + + '<a href="/projects/1/wiki/Test/edit\?section=5"><img src="/images/edit.png(\?\d+)?" alt="Edit" /></a></div>' + '<a name="Subtitle-after-pre-tag"></a>' + '<h2 >Subtitle after pre tag<a href="#Subtitle-after-pre-tag" class="wiki-anchor">¶</a></h2>'), result @@ -1323,8 +1323,9 @@ RAW def test_thumbnail_tag a = Attachment.find(3) - assert_equal '<a href="/attachments/3/logo.gif" title="logo.gif"><img alt="3" src="/attachments/thumbnail/3" /></a>', - thumbnail_tag(a) + assert_select_in thumbnail_tag(a), + 'a[href=?][title=?] img[alt="3"][src=?]', + "/attachments/3/logo.gif", "logo.gif", "/attachments/thumbnail/3" end def test_link_to_project diff --git a/test/unit/helpers/groups_helper_test.rb b/test/unit/helpers/groups_helper_test.rb index 177287305..19a08134e 100644 --- a/test/unit/helpers/groups_helper_test.rb +++ b/test/unit/helpers/groups_helper_test.rb @@ -28,7 +28,7 @@ class GroupsHelperTest < ActionView::TestCase group = Group.generate! result = render_principals_for_new_group_users(group) - assert_select_in result, 'input[name=?][value=2]', 'user_ids[]' + assert_select_in result, 'input[name=?][value="2"]', 'user_ids[]' end def test_render_principals_for_new_group_users_with_limited_results_should_paginate diff --git a/test/unit/helpers/members_helper_test.rb b/test/unit/helpers/members_helper_test.rb index b8154914a..0c20aa4e7 100644 --- a/test/unit/helpers/members_helper_test.rb +++ b/test/unit/helpers/members_helper_test.rb @@ -29,7 +29,7 @@ class MembersHelperTest < ActionView::TestCase project = Project.generate! result = render_principals_for_new_members(project) - assert_select_in result, 'input[name=?][value=2]', 'membership[user_ids][]' + assert_select_in result, 'input[name=?][value="2"]', 'membership[user_ids][]' end def test_render_principals_for_new_members_with_limited_results_should_paginate diff --git a/test/unit/helpers/projects_helper_test.rb b/test/unit/helpers/projects_helper_test.rb index 6f3b143d9..713384527 100644 --- a/test/unit/helpers/projects_helper_test.rb +++ b/test/unit/helpers/projects_helper_test.rb @@ -42,12 +42,12 @@ class ProjectsHelperTest < ActionView::TestCase def test_link_to_version_within_project @project = Project.find(2) User.current = User.find(1) - assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5)) + assert_equal '<a title="07/01/2006" href="/versions/5">Alpha</a>', link_to_version(Version.find(5)) end def test_link_to_version User.current = User.find(1) - assert_equal '<a href="/versions/5" title="07/01/2006">Alpha</a>', link_to_version(Version.find(5)) + assert_equal '<a title="07/01/2006" href="/versions/5">Alpha</a>', link_to_version(Version.find(5)) end def test_link_to_version_without_effective_date diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb index ae8b96c9b..d96f01651 100644 --- a/test/unit/lib/redmine/helpers/gantt_test.rb +++ b/test/unit/lib/redmine/helpers/gantt_test.rb @@ -128,14 +128,14 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase setup_subjects @output_buffer = @gantt.subjects assert_select "div.project-name a", /#{@project.name}/ - assert_select "div.project-name[style*=left:4px]" + assert_select 'div.project-name[style*="left:4px"]' end test "#subjects version should be rendered" do setup_subjects @output_buffer = @gantt.subjects assert_select "div.version-name a", /#{@version.name}/ - assert_select "div.version-name[style*=left:24px]" + assert_select 'div.version-name[style*="left:24px"]' end test "#subjects version without assigned issues should not be rendered" do @@ -152,7 +152,7 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase setup_subjects @output_buffer = @gantt.subjects assert_select "div.issue-subject", /#{@issue.subject}/ - assert_select "div.issue-subject[style*=left:44px]" + assert_select 'div.issue-subject[style*="left:44px"]' end test "#subjects issue assigned to a shared version of another project should be rendered" do @@ -197,12 +197,12 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase ) @output_buffer = @gantt.subjects # parent task 44px - assert_select "div.issue-subject[style*=left:44px]", /#{@issue.subject}/ + assert_select 'div.issue-subject[style*="left:44px"]', /#{@issue.subject}/ # children 64px - assert_select "div.issue-subject[style*=left:64px]", /child1/ - assert_select "div.issue-subject[style*=left:64px]", /child2/ + assert_select 'div.issue-subject[style*="left:64px"]', /child1/ + assert_select 'div.issue-subject[style*="left:64px"]', /child2/ # grandchild 84px - assert_select "div.issue-subject[style*=left:84px]", /grandchild/, @output_buffer + assert_select 'div.issue-subject[style*="left:84px"]', /grandchild/, @output_buffer end test "#lines" do @@ -298,7 +298,7 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase test "#subject should use the indent option to move the div to the right" do create_gantt @output_buffer = @gantt.subject('subject', :format => :html, :indent => 40) - assert_select "div[style*=left:40]" + assert_select 'div[style*="left:40"]' end test "#line_for_project" do @@ -332,65 +332,65 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase test "#line todo line should start from the starting point on the left" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_todo[style*=left:28px]", 1 + assert_select 'div.task_todo[style*="left:28px"]', 1 end test "#line todo line should be the total width" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_todo[style*=width:58px]", 1 + assert_select 'div.task_todo[style*="width:58px"]', 1 end test "#line late line should start from the starting point on the left" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_late[style*=left:28px]", 1 + assert_select 'div.task_late[style*="left:28px"]', 1 end test "#line late line should be the total delayed width" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_late[style*=width:30px]", 1 + assert_select 'div.task_late[style*="width:30px"]', 1 end test "#line done line should start from the starting point on the left" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_done[style*=left:28px]", 1 + assert_select 'div.task_done[style*="left:28px"]', 1 end test "#line done line should be the width for the done ratio" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, false, 'line', :format => :html, :zoom => 4) # 15 days * 4 px * 30% - 2 px for borders = 16 px - assert_select "div.task_done[style*=width:16px]", 1 + assert_select 'div.task_done[style*="width:16px"]', 1 end test "#line done line should be the total width for 100% done ratio" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4) # 15 days * 4 px - 2 px for borders = 58 px - assert_select "div.task_done[style*=width:58px]", 1 + assert_select 'div.task_done[style*="width:58px"]', 1 end test "#line done line should be the total width for 100% done ratio with same start and end dates" do create_gantt @output_buffer = @gantt.line(today + 7, today + 7, 100, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_done[style*=width:2px]", 1 + assert_select 'div.task_done[style*="width:2px"]', 1 end test "#line done line should not be the total done width if the gantt starts after start date" do create_gantt @output_buffer = @gantt.line(today - 16, today - 2, 30, false, 'line', :format => :html, :zoom => 4) - assert_select "div.task_done[style*=left:0px]", 1 - assert_select "div.task_done[style*=width:8px]", 1 + assert_select 'div.task_done[style*="left:0px"]', 1 + assert_select 'div.task_done[style*="width:8px"]', 1 end test "#line starting marker should appear at the start date" do create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4) assert_select "div.starting", 1 - assert_select "div.starting[style*=left:28px]", 1 + assert_select 'div.starting[style*="left:28px"]', 1 end test "#line starting marker should not appear if the start date is before gantt start date" do @@ -403,7 +403,7 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase create_gantt @output_buffer = @gantt.line(today - 7, today + 7, 30, true, 'line', :format => :html, :zoom => 4) assert_select "div.ending", 1 - assert_select "div.ending[style*=left:88px]", 1 + assert_select 'div.ending[style*="left:88px"]', 1 end test "#line ending marker should not appear if the end date is before gantt start date" do diff --git a/test/unit/lib/redmine/menu_manager/menu_helper_test.rb b/test/unit/lib/redmine/menu_manager/menu_helper_test.rb index d0e905514..dd5e785d5 100644 --- a/test/unit/lib/redmine/menu_manager/menu_helper_test.rb +++ b/test/unit/lib/redmine/menu_manager/menu_helper_test.rb @@ -51,14 +51,14 @@ class Redmine::MenuManager::MenuHelperTest < ActionView::TestCase node = Redmine::MenuManager::MenuItem.new(:testing, :issues_path) @output_buffer = render_menu_node(node, nil) - assert_select "a[href=/issues]", "Testing" + assert_select 'a[href="/issues"]', "Testing" end def test_render_menu_node_with_symbol_as_url_and_project node = Redmine::MenuManager::MenuItem.new(:testing, :project_issues_path) @output_buffer = render_menu_node(node, Project.find(1)) - assert_select "a[href=/projects/ecookbook/issues]", "Testing" + assert_select 'a[href="/projects/ecookbook/issues"]', "Testing" end def test_render_menu_node_with_nested_items diff --git a/test/unit/mailer_test.rb b/test/unit/mailer_test.rb index b020e5303..1c732674b 100644 --- a/test/unit/mailer_test.rb +++ b/test/unit/mailer_test.rb @@ -19,7 +19,7 @@ require File.expand_path('../../test_helper', __FILE__) class MailerTest < ActiveSupport::TestCase include Redmine::I18n - include ActionDispatch::Assertions::SelectorAssertions + include Rails::Dom::Testing::Assertions fixtures :projects, :enabled_modules, :issues, :users, :email_addresses, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, @@ -61,11 +61,14 @@ class MailerTest < ActiveSupport::TestCase # link to a changeset assert_select 'a[href=?][title=?]', 'https://mydomain.foo/projects/ecookbook/repository/revisions/2', - 'This commit fixes #1, #2 and references #1 & #3', + 'This commit fixes #1, #2 and references #1 & #3', :text => 'r2' # link to a description diff - assert_select 'a[href=?][title=?]', - 'https://mydomain.foo/journals/diff/3?detail_id=4', + assert_select 'a[href^=?][title=?]', + # should be https://mydomain.foo/journals/diff/3?detail_id=4 + # but the Rails 4.2 DOM assertion doesn't handle the ? in the + # attribute value + 'https://mydomain.foo/journals/diff/3', 'View differences', :text => 'diff' # link to an attachment @@ -100,11 +103,14 @@ class MailerTest < ActiveSupport::TestCase # link to a changeset assert_select 'a[href=?][title=?]', 'http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2', - 'This commit fixes #1, #2 and references #1 & #3', + 'This commit fixes #1, #2 and references #1 & #3', :text => 'r2' # link to a description diff - assert_select 'a[href=?][title=?]', - 'http://mydomain.foo/rdm/journals/diff/3?detail_id=4', + assert_select 'a[href^=?][title=?]', + # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4 + # but the Rails 4.2 DOM assertion doesn't handle the ? in the + # attribute value + 'http://mydomain.foo/rdm/journals/diff/3', 'View differences', :text => 'diff' # link to an attachment @@ -150,11 +156,14 @@ class MailerTest < ActiveSupport::TestCase # link to a changeset assert_select 'a[href=?][title=?]', 'http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2', - 'This commit fixes #1, #2 and references #1 & #3', + 'This commit fixes #1, #2 and references #1 & #3', :text => 'r2' # link to a description diff - assert_select 'a[href=?][title=?]', - 'http://mydomain.foo/rdm/journals/diff/3?detail_id=4', + assert_select 'a[href^=?][title=?]', + # should be http://mydomain.foo/rdm/journals/diff/3?detail_id=4 + # but the Rails 4.2 DOM assertion doesn't handle the ? in the + # attribute value + 'http://mydomain.foo/rdm/journals/diff/3', 'View differences', :text => 'diff' # link to an attachment @@ -762,10 +771,6 @@ class MailerTest < ActiveSupport::TestCase end end - def test_mail_should_return_a_mail_message - assert_kind_of ::Mail::Message, Mailer.test_email(User.find(1)) - end - def test_with_synched_deliveries_should_yield_with_synced_deliveries ActionMailer::Base.delivery_method = :async_smtp ActionMailer::Base.async_smtp_settings = {:foo => 'bar'} |