Files
openfoodnetwork/spec/support/api_helper.rb
Rob Harrington ffa8a8c7d6 Create Api::BaseController to allow use of ActiveModelSerializers
Also add index action to Api::CustomersController
2018-06-22 15:39:47 +10:00

16 lines
330 B
Ruby

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
end
end