diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index c074a6ca2..483468db0 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -38,7 +38,7 @@ class SearchControllerTest < ActionController::TestCase get :index, :q => "cook" assert_response :success assert_template 'index' - assert assigns(:results).include?(Project.find(1)) + assert assigns(:results).map(&:first).include?(Project.find(1)) end def test_search_on_archived_project_should_return_404 @@ -71,9 +71,9 @@ class SearchControllerTest < ActionController::TestCase assert_response :success assert_template 'index' - assert assigns(:results).include?(Issue.find(2)) - assert assigns(:results).include?(Issue.find(5)) - assert assigns(:results).include?(Changeset.find(101)) + assert assigns(:results).map(&:first).include?(Issue.find(2)) + assert assigns(:results).map(&:first).include?(Issue.find(5)) + assert assigns(:results).map(&:first).include?(Changeset.find(101)) assert_select 'dt.issue a', :text => /Add ingredients categories/ assert_select 'dd', :text => /should be classified by categories/ @@ -89,8 +89,8 @@ class SearchControllerTest < ActionController::TestCase assert_equal true, assigns(:all_words) assert_equal false, assigns(:titles_only) - assert assigns(:results).include?(Issue.find(8)) - assert assigns(:results).include?(Issue.find(5)) + assert assigns(:results).map(&:first).include?(Issue.find(8)) + assert assigns(:results).map(&:first).include?(Issue.find(5)) assert_select 'dt.issue.closed a', :text => /Closed/ end @@ -99,7 +99,7 @@ class SearchControllerTest < ActionController::TestCase get :index, :q => 'searchkeyword', :issues => 1 assert_response :success - assert_include Issue.find(2), assigns(:results) + assert_include Issue.find(2), assigns(:results).map(&:first) end def test_search_issues_with_multiple_matches_in_journals_should_return_issue_once @@ -108,7 +108,7 @@ class SearchControllerTest < ActionController::TestCase get :index, :q => 'searchkeyword', :issues => 1 assert_response :success - assert_include Issue.find(2), assigns(:results) + assert_include Issue.find(2), assigns(:results).map(&:first) assert_equal 1, assigns(:results).size end @@ -119,12 +119,12 @@ class SearchControllerTest < ActionController::TestCase Role.find(1).add_permission! :view_private_notes get :index, :q => 'searchkeyword', :issues => 1 assert_response :success - assert_include Issue.find(2), assigns(:results) + assert_include Issue.find(2), assigns(:results).map(&:first) Role.find(1).remove_permission! :view_private_notes get :index, :q => 'searchkeyword', :issues => 1 assert_response :success - assert_not_include Issue.find(2), assigns(:results) + assert_not_include Issue.find(2), assigns(:results).map(&:first) end def test_search_all_projects_with_scope_param @@ -139,8 +139,8 @@ class SearchControllerTest < ActionController::TestCase get :index, :id => 1, :q => 'recipe subproject', :scope => 'my_projects', :all_words => '' assert_response :success assert_template 'index' - assert assigns(:results).include?(Issue.find(1)) - assert !assigns(:results).include?(Issue.find(5)) + assert assigns(:results).map(&:first).include?(Issue.find(1)) + assert !assigns(:results).map(&:first).include?(Issue.find(5)) end def test_search_my_projects_without_memberships @@ -155,8 +155,8 @@ class SearchControllerTest < ActionController::TestCase get :index, :id => 1, :q => 'recipe subproject', :scope => 'subprojects', :all_words => '' assert_response :success assert_template 'index' - assert assigns(:results).include?(Issue.find(1)) - assert assigns(:results).include?(Issue.find(5)) + assert assigns(:results).map(&:first).include?(Issue.find(1)) + assert assigns(:results).map(&:first).include?(Issue.find(5)) end def test_search_without_searchable_custom_fields @@ -175,7 +175,7 @@ class SearchControllerTest < ActionController::TestCase def test_search_with_searchable_custom_fields get :index, :id => 1, :q => "stringforcustomfield" assert_response :success - results = assigns(:results) + results = assigns(:results).map(&:first) assert_not_nil results assert_equal 1, results.size assert results.include?(Issue.find(7)) @@ -186,7 +186,7 @@ class SearchControllerTest < ActionController::TestCase attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' get :index, :id => 1, :q => 'search_attachments', :attachments => '0' - results = assigns(:results) + results = assigns(:results).map(&:first) assert_equal 1, results.size assert_equal issue, results.first end @@ -196,7 +196,7 @@ class SearchControllerTest < ActionController::TestCase attachment = Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' get :index, :id => 1, :q => 'search_attachments', :attachments => 'only' - results = assigns(:results) + results = assigns(:results).map(&:first) assert_equal 1, results.size assert_equal attachment.container, results.first end @@ -206,7 +206,7 @@ class SearchControllerTest < ActionController::TestCase Attachment.generate! :container => Issue.find(1), :filename => 'search_attachments.patch' get :index, :id => 1, :q => 'search_attachments', :attachments => '1' - results = assigns(:results) + results = assigns(:results).map(&:first) assert_equal 2, results.size end @@ -215,7 +215,7 @@ class SearchControllerTest < ActionController::TestCase Issue.generate! :subject => 'search_open', :status_id => 5 get :index, :id => 1, :q => 'search_open', :open_issues => '1' - results = assigns(:results) + results = assigns(:results).map(&:first) assert_equal 1, results.size end @@ -223,7 +223,7 @@ class SearchControllerTest < ActionController::TestCase # 'all words' is on by default get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1' assert_equal true, assigns(:all_words) - results = assigns(:results) + results = assigns(:results).map(&:first) assert_not_nil results assert_equal 1, results.size assert results.include?(Issue.find(3)) @@ -232,7 +232,7 @@ class SearchControllerTest < ActionController::TestCase def test_search_one_of_the_words get :index, :id => 1, :q => 'recipe updating saving', :all_words => '' assert_equal false, assigns(:all_words) - results = assigns(:results) + results = assigns(:results).map(&:first) assert_not_nil results assert_equal 3, results.size assert results.include?(Issue.find(3)) @@ -240,7 +240,7 @@ class SearchControllerTest < ActionController::TestCase def test_search_titles_only_without_result get :index, :id => 1, :q => 'recipe updating saving', :titles_only => '1' - results = assigns(:results) + results = assigns(:results).map(&:first) assert_not_nil results assert_equal 0, results.size end @@ -248,7 +248,7 @@ class SearchControllerTest < ActionController::TestCase def test_search_titles_only get :index, :id => 1, :q => 'recipe', :titles_only => '1' assert_equal true, assigns(:titles_only) - results = assigns(:results) + results = assigns(:results).map(&:first) assert_not_nil results assert_equal 2, results.size end @@ -257,7 +257,7 @@ class SearchControllerTest < ActionController::TestCase Issue.where(:id => 1).update_all("description = 'This is a searchkeywordinthecontent'") get :index, :id => 1, :q => 'searchkeywordinthecontent', :titles_only => '' assert_equal false, assigns(:titles_only) - results = assigns(:results) + results = assigns(:results).map(&:first) assert_not_nil results assert_equal 1, results.size end @@ -267,19 +267,19 @@ class SearchControllerTest < ActionController::TestCase get :index, :q => 'search_with_limited_results' assert_response :success - assert_equal issue[0..9], assigns(:results) + assert_equal issue[0..9], assigns(:results).map(&:first) get :index, :q => 'search_with_limited_results', :page => 2 assert_response :success - assert_equal issue[10..19], assigns(:results) + assert_equal issue[10..19], assigns(:results).map(&:first) get :index, :q => 'search_with_limited_results', :page => 3 assert_response :success - assert_equal issue[20..24], assigns(:results) + assert_equal issue[20..24], assigns(:results).map(&:first) get :index, :q => 'search_with_limited_results', :page => 4 assert_response :success - assert_equal [], assigns(:results) + assert_equal [], assigns(:results).map(&:first) end def test_search_with_invalid_project_id diff --git a/test/integration/api_test/search_test.rb b/test/integration/api_test/search_test.rb index 21351ce83..407aa880f 100644 --- a/test/integration/api_test/search_test.rb +++ b/test/integration/api_test/search_test.rb @@ -61,11 +61,11 @@ class Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base assert_select 'result', :count => assigns(:results).count assigns(:results).size.times.each do |i| assert_select 'result' do - assert_select 'id', :text => assigns(:results)[i].id.to_s - assert_select 'title', :text => assigns(:results)[i].event_title - assert_select 'type', :text => assigns(:results)[i].event_type - assert_select 'url', :text => url_for(assigns(:results)[i].event_url(:only_path => false)) - assert_select 'description', :text => assigns(:results)[i].event_description + assert_select 'id', :text => assigns(:results)[i].first.id.to_s + assert_select 'title', :text => assigns(:results)[i].first.event_title + assert_select 'type', :text => assigns(:results)[i].first.event_type + assert_select 'url', :text => url_for(assigns(:results)[i].first.event_url(:only_path => false)) + assert_select 'description', :text => assigns(:results)[i].first.event_description assert_select 'datetime' end end