mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Merge pull request #13587 from mkllnk/json-response
Clean up request specs testing JSON
This commit is contained in:
@@ -19,6 +19,8 @@ RSpec.describe "Customers", swagger_doc: "v1.yaml", feature: :api_v1 do
|
||||
}
|
||||
let!(:customer2) { create(:customer, enterprise: enterprise1, created_manually: true,) }
|
||||
let!(:customer3) { create(:customer, enterprise: enterprise2, created_manually: true,) }
|
||||
let(:json_response_ids) { json_response[:data]&.pluck(:id) }
|
||||
let(:json_error_detail) { json_response[:errors][0][:detail] }
|
||||
|
||||
before do
|
||||
login_as enterprise1.owner
|
||||
|
||||
@@ -3,23 +3,7 @@
|
||||
module OpenFoodNetwork
|
||||
module ApiHelper
|
||||
def json_response
|
||||
json_response = JSON.parse(response.body)
|
||||
case json_response
|
||||
when Hash
|
||||
json_response.with_indifferent_access
|
||||
when Array
|
||||
json_response.map(&:with_indifferent_access)
|
||||
else
|
||||
json_response
|
||||
end
|
||||
end
|
||||
|
||||
def json_response_ids
|
||||
json_response[:data]&.pluck(:id)
|
||||
end
|
||||
|
||||
def json_error_detail
|
||||
json_response[:errors][0][:detail]
|
||||
response.parsed_body
|
||||
end
|
||||
|
||||
def assert_unauthorized!
|
||||
|
||||
Reference in New Issue
Block a user