summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-03-19 10:27:55 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-03-19 10:27:55 +0000
commite1aa18b33388901d47476df4a68a1d25f27a9658 (patch)
tree01da270d019d1df51f4a4f4a7fd4a488a2e7f5f4 /test/integration
parent7a812815833f0320d3b2d52ac71af63f324b0028 (diff)
downloadredmine-e1aa18b33388901d47476df4a68a1d25f27a9658.tar.gz
redmine-e1aa18b33388901d47476df4a68a1d25f27a9658.zip
Handle search pagination with the REST API (#6277).
git-svn-id: http://svn.redmine.org/redmine/trunk@15264 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/api_test/search_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/integration/api_test/search_test.rb b/test/integration/api_test/search_test.rb
index 9ec115409..21351ce83 100644
--- a/test/integration/api_test/search_test.rb
+++ b/test/integration/api_test/search_test.rb
@@ -71,4 +71,22 @@ class Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base
end
end
end
+
+ test "GET /search.xml should paginate" do
+ issue = (0..10).map {Issue.generate! :subject => 'search_with_limited_results'}.reverse.map(&:id)
+
+ get '/search.json', :q => 'search_with_limited_results', :limit => 4
+ json = ActiveSupport::JSON.decode(response.body)
+ assert_equal 11, json['total_count']
+ assert_equal 0, json['offset']
+ assert_equal 4, json['limit']
+ assert_equal issue[0..3], json['results'].map {|r| r['id']}
+
+ get '/search.json', :q => 'search_with_limited_results', :offset => 8, :limit => 4
+ json = ActiveSupport::JSON.decode(response.body)
+ assert_equal 11, json['total_count']
+ assert_equal 8, json['offset']
+ assert_equal 4, json['limit']
+ assert_equal issue[8..10], json['results'].map {|r| r['id']}
+ end
end