mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 09:46:02 +01:00
Handle search pagination with the REST API (#6277).
git-svn-id: http://svn.redmine.org/redmine/trunk@15264 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user