diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-12 20:49:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-12-12 20:49:31 +0000 |
commit | 2fe806a4a49cc3fcd7c2b7fe3a385d3a46ffbfd5 (patch) | |
tree | 82f8da72bfdc6e68c83cbecf3ffac2b5bcc9738a /test/functional/search_controller_test.rb | |
parent | 963719042a12e7833a95396036a662237a7939a0 (diff) | |
download | redmine-2fe806a4a49cc3fcd7c2b7fe3a385d3a46ffbfd5.tar.gz redmine-2fe806a4a49cc3fcd7c2b7fe3a385d3a46ffbfd5.zip |
Rewrites search engine to properly paginate results (#18631).
Instead of counting and retrieving results based on their timestamps, we now load all result ids then load the appropriate results by their ids. This also brings a 2x performance improvement as we search tokens in one of the 2 queries only.
git-svn-id: http://svn.redmine.org/redmine/trunk@13739 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/search_controller_test.rb')
-rw-r--r-- | test/functional/search_controller_test.rb | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index 4124985db..24dfa7d6f 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -75,8 +75,8 @@ class SearchControllerTest < ActionController::TestCase 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 assigns(:result_count_by_type).is_a?(Hash) + assert_equal 5, assigns(:result_count_by_type)['changesets'] assert_select 'a', :text => 'Changesets (5)' end @@ -222,20 +222,24 @@ class SearchControllerTest < ActionController::TestCase assert_equal 1, results.size end - def test_search_with_offset - get :index, :q => 'coo', :offset => '20080806073000' + def test_search_with_pagination + issue = (0..24).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse + + get :index, :q => 'search_with_limited_results' assert_response :success - results = assigns(:results) - assert results.any? - assert results.map(&:event_datetime).max < '20080806T073000'.to_time - end + assert_equal issue[0..9], assigns(:results) - def test_search_previous_with_offset - get :index, :q => 'coo', :offset => '20080806073000', :previous => '1' + get :index, :q => 'search_with_limited_results', :page => 2 assert_response :success - results = assigns(:results) - assert results.any? - assert results.map(&:event_datetime).min >= '20080806T073000'.to_time + assert_equal issue[10..19], assigns(:results) + + get :index, :q => 'search_with_limited_results', :page => 3 + assert_response :success + assert_equal issue[20..24], assigns(:results) + + get :index, :q => 'search_with_limited_results', :page => 4 + assert_response :success + assert_equal [], assigns(:results) end def test_search_with_invalid_project_id |