mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Sanitise pagination input for new API
This commit is contained in:
@@ -53,7 +53,7 @@ module JsonApiPagination
|
||||
end
|
||||
|
||||
def current_page
|
||||
params[:page] || 1
|
||||
(params[:page] || 1).to_i
|
||||
end
|
||||
|
||||
def total_pages
|
||||
|
||||
@@ -73,11 +73,14 @@ describe "Customers", type: :request do
|
||||
|
||||
describe "pagination" do
|
||||
it "renders the first page" do
|
||||
pending "pagination logic compares string with integer"
|
||||
|
||||
get "/api/v1/customers", params: { page: "1" }
|
||||
expect(json_response_ids).to eq [customer1.id.to_s, customer2.id.to_s]
|
||||
end
|
||||
|
||||
it "renders the second page" do
|
||||
get "/api/v1/customers", params: { page: "2", per_page: "1" }
|
||||
expect(json_response_ids).to eq [customer2.id.to_s]
|
||||
end
|
||||
end
|
||||
|
||||
post "Create customer" do
|
||||
|
||||
Reference in New Issue
Block a user