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

Adding max_pages for pagination response #614

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 8 additions & 2 deletions lib/blacklight/solr_response/pagination_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ def total_count #:nodoc:
# Next page number in the collection
def next_page
current_page + 1 unless last_page?
end
end

# Previous page number in the collection
def prev_page
current_page - 1 unless first_page?
end
end

# kaminari expects a method of :max_pages; if it is nil it handles calculation
def max_pages #:nodoc:
nil
end

end
6 changes: 6 additions & 0 deletions spec/lib/blacklight/solr_response/group_response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
expect(group.group_limit).to eq 5
end
end

describe "max_pages" do
it "should get maximum number of pages" do
expect(group.max_pages).to be_nil
end
end
end

def create_response(response, params = {})
Expand Down