Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/tracker_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ def get(path, options = {})
# @return [Array]
def paginate(path, options = {}, &block)
opts = parse_query_and_convenience_headers path, options.dup
auto_paginate = opts[:params].delete(:auto_paginate) { |k| @auto_paginate }
@last_response = request :get, opts
data = @last_response.body
raise TrackerApi::Errors::UnexpectedData, 'Array expected' unless data.is_a? Array

if @auto_paginate
if auto_paginate
pager = Pagination.new @last_response.headers

while pager.more?
Expand Down
11 changes: 11 additions & 0 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@
end
end

it 'allows auto pagination to be turned off when just a subset of a list is desired' do
VCR.use_cassette('client: get limited stories with no pagination', record: :new_episodes) do
project = client.project(project_id)

# force no pagination
stories = project.stories(limit: 7, auto_paginate: false)
stories.wont_be_empty
stories.length.must_equal 7
end
end

it 'can handle negative offsets' do
VCR.use_cassette('client: done iterations with pagination', record: :new_episodes) do
project = client.project(project_id)
Expand Down