Make json_response test helper deal with error response

It raised an error:

     NoMethodError:
       undefined method `map' for nil:NilClass
This commit is contained in:
Maikel Linke
2022-02-15 13:03:55 +11:00
parent 414bf5d074
commit 75fc35574e
2 changed files with 10 additions and 1 deletions

View File

@@ -71,6 +71,15 @@ describe "Customers", type: :request do
end
end
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
end
post "Create customer" do
tags "Customers"
consumes "application/json"

View File

@@ -15,7 +15,7 @@ module OpenFoodNetwork
end
def json_response_ids
json_response[:data].map{ |item| item["id"] }
json_response[:data]&.map{ |item| item["id"] }
end
def json_error_detail