We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 18eccd6 + a099535 commit dbe1d99Copy full SHA for dbe1d99
lib/api-pagination.rb
@@ -25,7 +25,7 @@ def pages_from(collection)
25
pages[:prev] = collection.current_page - 1
26
end
27
28
- unless collection.last_page?
+ unless collection.last_page? || (ApiPagination.config.paginator == :kaminari && collection.out_of_range?)
29
pages[:last] = collection.total_pages
30
pages[:next] = collection.current_page + 1
31
spec/api-pagination_spec.rb
@@ -26,5 +26,15 @@
}
)
+
+ describe '.pages_from' do
+ subject { described_class.pages_from collection }
32
33
+ context 'on empty collection' do
34
+ let(:collection) { ApiPagination.paginate [], page: 1 }
35
36
+ it { is_expected.to be_empty }
37
+ end
38
39
40
0 commit comments