mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-04 22:16:08 +00:00
Add dfc-b:isVariantOf to supplied products
This commit is contained in:
@@ -10,6 +10,10 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
variant.supplier_id,
|
||||
spree_product_id: variant.product_id
|
||||
)
|
||||
product_group_id = urls.enterprise_product_group_url(
|
||||
enterprise_id: variant.supplier_id,
|
||||
id: variant.product_id,
|
||||
)
|
||||
|
||||
DfcProvider::SuppliedProduct.new(
|
||||
id,
|
||||
@@ -17,6 +21,7 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
description: variant.description,
|
||||
productType: product_type(variant),
|
||||
quantity: QuantitativeValueBuilder.quantity(variant),
|
||||
isVariantOf: [product_group_id],
|
||||
spree_product_uri: product_uri,
|
||||
spree_product_id: variant.product.id,
|
||||
image_url: variant.product&.image&.url(:product)
|
||||
|
||||
@@ -6,6 +6,7 @@ DfcProvider::Engine.routes.draw do
|
||||
resources :catalog_items, only: [:index, :show, :update]
|
||||
resources :offers, only: [:show, :update]
|
||||
resources :supplied_products, only: [:create, :show, :update]
|
||||
resources :product_groups, only: [:show]
|
||||
resources :social_medias, only: [:show]
|
||||
end
|
||||
resources :enterprise_groups, only: [:index, :show] do
|
||||
|
||||
@@ -191,6 +191,7 @@ RSpec.describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml", rswa
|
||||
|
||||
run_test! do
|
||||
expect(response.body).to include variant.name
|
||||
expect(json_response["dfc-b:isVariantOf"]).to eq "http://test.host/api/dfc/enterprises/10000/product_groups/90000"
|
||||
expect(json_response["ofn:spree_product_id"]).to eq 90_000
|
||||
expect(json_response["dfc-b:hasType"]).to eq("dfc-pt:processed-vegetable")
|
||||
expect(json_response["ofn:image"]).to include("logo-white.png")
|
||||
|
||||
@@ -177,6 +177,7 @@ paths:
|
||||
"@type": dfc-b:QuantitativeValue
|
||||
dfc-b:hasUnit: dfc-m:Gram
|
||||
dfc-b:value: 1.0
|
||||
dfc-b:isVariantOf: http://test.host/api/dfc/enterprises/10000/product_groups/90000
|
||||
ofn:spree_product_id: 90000
|
||||
ofn:spree_product_uri: http://test.host/api/dfc/enterprises/10000?spree_product_id=90000
|
||||
- "@id": http://test.host/api/dfc/enterprises/10000/offers/10001
|
||||
@@ -463,6 +464,7 @@ paths:
|
||||
dfc-b:hasUnit: dfc-m:Gram
|
||||
dfc-b:value: 1.0
|
||||
dfc-b:image: http://test.host/rails/active_storage/url/logo-white.png
|
||||
dfc-b:isVariantOf: http://test.host/api/dfc/enterprises/10000/product_groups/90000
|
||||
ofn:spree_product_id: 90000
|
||||
ofn:spree_product_uri: http://test.host/api/dfc/enterprises/10000?spree_product_id=90000
|
||||
ofn:image: http://test.host/rails/active_storage/url/logo-white.png
|
||||
@@ -615,6 +617,7 @@ paths:
|
||||
"@type": dfc-b:QuantitativeValue
|
||||
dfc-b:hasUnit: dfc-m:Gram
|
||||
dfc-b:value: 6.0
|
||||
dfc-b:isVariantOf: http://test.host/api/dfc/enterprises/10000/product_groups/90000
|
||||
ofn:spree_product_id: 90000
|
||||
ofn:spree_product_uri: http://test.host/api/dfc/enterprises/10000?spree_product_id=90000
|
||||
dfc-b:image: http://test.host/rails/active_storage/url/logo-white.png
|
||||
@@ -675,6 +678,7 @@ paths:
|
||||
dfc-b:hasUnit: dfc-m:Gram
|
||||
dfc-b:value: 1.0
|
||||
dfc-b:image: http://test.host/rails/active_storage/url/logo-white.png
|
||||
dfc-b:isVariantOf: http://test.host/api/dfc/enterprises/10000/product_groups/90000
|
||||
ofn:spree_product_id: 90000
|
||||
ofn:spree_product_uri: http://test.host/api/dfc/enterprises/10000?spree_product_id=90000
|
||||
ofn:image: http://test.host/rails/active_storage/url/logo-white.png
|
||||
|
||||
Reference in New Issue
Block a user