mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Allow updating of product type
This commit is contained in:
@@ -52,6 +52,7 @@ class SuppliedProductBuilder < DfcBuilder
|
||||
def self.apply(supplied_product, variant)
|
||||
variant.product.assign_attributes(
|
||||
description: supplied_product.description,
|
||||
primary_taxon: taxon(supplied_product)
|
||||
)
|
||||
|
||||
variant.display_name = supplied_product.name
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"dfc-b:hasUnit": "dfc-m:Piece",
|
||||
"dfc-b:value": 17
|
||||
},
|
||||
"dfc-b:hasType": "dfc-pt:non-local-vegetable",
|
||||
"dfc-b:hasType": "dfc-pt:drink",
|
||||
"dfc-b:lifetime": "",
|
||||
"dfc-b:name": "Pesto novo",
|
||||
"dfc-b:totalTheoreticalStock": 0,
|
||||
|
||||
@@ -172,6 +172,10 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml", rswag_auto
|
||||
end
|
||||
|
||||
put "Update SuppliedProduct" do
|
||||
let!(:drink_taxon) {
|
||||
create(:taxon, name: "Drink", dfc_name: "drink")
|
||||
}
|
||||
|
||||
consumes "application/json"
|
||||
|
||||
parameter name: :supplied_product, in: :body, schema: {
|
||||
@@ -197,6 +201,7 @@ describe "SuppliedProducts", type: :request, swagger_doc: "dfc.yaml", rswag_auto
|
||||
}.to change { variant.description }.to("DFC-Pesto updated")
|
||||
.and change { variant.display_name }.to("Pesto novo")
|
||||
.and change { variant.unit_value }.to(17)
|
||||
.and change { variant.product.primary_taxon }.to(drink_taxon)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user