From 375b3a3cb0b0fc918f21f0242ba1bf2c29eab232 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 12 May 2023 16:49:47 +1000 Subject: [PATCH] Update variant's quantity from DFC --- .../controllers/dfc_provider/supplied_products_controller.rb | 5 +++++ engines/dfc_provider/spec/requests/supplied_products_spec.rb | 1 + .../dfc_provider/spec/support/patch_supplied_product.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engines/dfc_provider/app/controllers/dfc_provider/supplied_products_controller.rb b/engines/dfc_provider/app/controllers/dfc_provider/supplied_products_controller.rb index 78f513a5e1..034770bab2 100644 --- a/engines/dfc_provider/app/controllers/dfc_provider/supplied_products_controller.rb +++ b/engines/dfc_provider/app/controllers/dfc_provider/supplied_products_controller.rb @@ -18,6 +18,11 @@ module DfcProvider variant.product.update!( description: dfc_request["dfc-b:description"], ) + + # This input is DFC v1.6 currently sent by the DFC Prototype. + variant.update!( + unit_value: dfc_request["dfc-b:quantity"], + ) end private diff --git a/engines/dfc_provider/spec/requests/supplied_products_spec.rb b/engines/dfc_provider/spec/requests/supplied_products_spec.rb index 593ce7c34d..f48d761561 100644 --- a/engines/dfc_provider/spec/requests/supplied_products_spec.rb +++ b/engines/dfc_provider/spec/requests/supplied_products_spec.rb @@ -51,6 +51,7 @@ describe "SuppliedProducts", type: :request do expect(response).to have_http_status :success variant.reload }.to change { variant.description }.to("DFC-Pesto updated") + .and change { variant.unit_value }.to(17) end end end diff --git a/engines/dfc_provider/spec/support/patch_supplied_product.json b/engines/dfc_provider/spec/support/patch_supplied_product.json index a13afd9299..86230c7e7a 100644 --- a/engines/dfc_provider/spec/support/patch_supplied_product.json +++ b/engines/dfc_provider/spec/support/patch_supplied_product.json @@ -81,5 +81,5 @@ } }, "dfc-b:description": "DFC-Pesto updated", - "dfc-b:quantity": 0 + "dfc-b:quantity": 17 }