Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the inconsistency in the #first_page method #991

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion kaminari-core/lib/kaminari/models/page_scope_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def prev_page

# First page of the collection?
def first_page?
current_page == 1
!out_of_range? && (current_page == 1)
end

# Last page of the collection?
Expand Down
6 changes: 6 additions & 0 deletions kaminari-core/test/models/active_record/scopes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ def shutdown
test 'not on first page' do
assert_false model_class.page(5).per(10).first_page?
end

test 'on first page with no record' do
model_class.delete_all

assert_false model_class.page(1).first_page?
end
end

sub_test_case '#last_page?' do
Expand Down