mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-19 04:49:15 +00:00
Simplify with extracted helper method
This commit is contained in:
@@ -103,7 +103,7 @@ describe "CatalogItems", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml",
|
||||
consumes "application/json"
|
||||
|
||||
parameter name: :catalog_item, in: :body, schema: {
|
||||
example: JSON.parse(DfcProvider::Engine.root.join("spec/support/patch_catalog_item.json").read)
|
||||
example: ExampleJson.read("patch_catalog_item")
|
||||
}
|
||||
|
||||
before { product }
|
||||
|
||||
@@ -103,9 +103,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc-v1.7/swagger.yaml
|
||||
parameter name: :supplied_product, in: :body, schema: {}
|
||||
|
||||
let(:id) { variant.id }
|
||||
let(:supplied_product) do
|
||||
JSON.parse(DfcProvider::Engine.root.join("spec/support/patch_supplied_product.json").read)
|
||||
end
|
||||
let(:supplied_product) { ExampleJson.read("patch_supplied_product") }
|
||||
|
||||
response "401", "unauthorized" do
|
||||
before { login_as nil }
|
||||
|
||||
8
engines/dfc_provider/spec/support/example_json.rb
Normal file
8
engines/dfc_provider/spec/support/example_json.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ExampleJson
|
||||
def self.read(name)
|
||||
pathname = DfcProvider::Engine.root.join("spec/support/#{name}.json")
|
||||
JSON.parse(pathname.read)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user