mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-17 04:34:24 +00:00
Update variant name instead of product via DFC
A DFC SuppliedProduct relates to a Spree::Variant and when updating its name we only want to change the name for that variant. Otherwise, when we update the name of the product, it would update the name for all variants and all the corresponding SuppliedProducts.
This commit is contained in:
@@ -49,10 +49,10 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
|
||||
def self.apply(supplied_product, variant)
|
||||
variant.product.assign_attributes(
|
||||
name: supplied_product.name,
|
||||
description: supplied_product.description,
|
||||
)
|
||||
|
||||
variant.display_name = supplied_product.name
|
||||
QuantitativeValueBuilder.apply(supplied_product.quantity, variant.product)
|
||||
variant.unit_value = variant.product.unit_value
|
||||
end
|
||||
|
||||
@@ -188,7 +188,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml", rswag_auto
|
||||
submit_request(example.metadata)
|
||||
variant.reload
|
||||
}.to change { variant.description }.to("DFC-Pesto updated")
|
||||
.and change { variant.name }.to("Pesto novo")
|
||||
.and change { variant.display_name }.to("Pesto novo")
|
||||
.and change { variant.unit_value }.to(17)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -489,7 +489,7 @@ paths:
|
||||
"@context": https://www.datafoodconsortium.org
|
||||
"@id": http://test.host/api/dfc/enterprises/10000/supplied_products/10001
|
||||
"@type": dfc-b:SuppliedProduct
|
||||
dfc-b:name: Apple - 6g
|
||||
dfc-b:name: Apple (6g)
|
||||
dfc-b:description: A delicious heritage apple
|
||||
dfc-b:hasType: dfc-pt:non-local-vegetable
|
||||
dfc-b:hasQuantity:
|
||||
|
||||
Reference in New Issue
Block a user