Allow updating of product type

This commit is contained in:
Gaetan Craig-Riou
2023-12-15 14:04:03 +11:00
parent a35e896a98
commit 25a820fe12
3 changed files with 7 additions and 1 deletions

View File

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

View File

@@ -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,

View File

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