From d9a2a70c5d971d4cf2c93bd837b897c8d935e7c0 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 7 Nov 2020 15:02:31 +0000 Subject: [PATCH] Fix broken order edit shipment As an administrator I want to create and edit orders as an enterprise manager viewing the edit page with different shipping methods can edit shipping method Failure/Error: expect(page).to have_content "Shipping: #{different_shipping_method_for_distributor1.name}" expected to find text "Shipping: Different" in "Logged in as : owen@romaguera.ca Account Logout Store DASHBOARD PRODUCTS ORDER CYCLES ORDERS REPORTS ENTERPRISES CUSTOMERS Order # R813516688 CANCEL ACTIONS BACK TO ORDER LIST John Doe - ADD PRODUCT NAME OR SKU (ENTER AT LEAST FIRST 4 CHARACTERS OF PRODUCT NAME) Select a variant 100 - PENDING ITEM DESCRIPTION PRICE QUANTITY TOTAL Product #3 - 9924 - 1g, S $10.00 1 x none $10.00 Product #4 - 5548 - 1g, S $10.00 1 x none $10.00 Product #5 - 8080 - 1g, S $10.00 1 x none $10.00 Product #6 - 3591 - 1g, S $10.00 1 x none $10.00 Product #7 - 6461 - 1g, S $10.00 1 x none $10.00 Product #8 - 4071 - 1g, S $110.00 1 x none $110.00 SHIPPING METHOD Different $0.00 Normal $0.00 Different $0.00 Tracking: U10000 LINE ITEM ADJUSTMENTS NAME AMOUNT Tax 1 10.0%: $10.00 ORDER ADJUSTMENTS NAME AMOUNT Transaction fee: $0.00 ORDER TOTAL $160.00 DISTRIBUTION Distributor: Enterprise 4 Order cycle: Order Cycle 2 UPDATE AND RECALCULATE FEES or BACK ORDER INFORMATION STATUS COMPLETE TOTAL : $160.00 SHIPMENT : PENDING PAYMENT : BALANCE DUE DATE COMPLETED : November 08, 2020 1:51 AM ORDER DETAILS CUSTOMER DETAILS ADJUSTMENTS PAYMENTS RETURN AUTHORIZATIONS" # ./spec/features/admin/order_spec.rb:291:in `block (5 levels) in ' --- app/controllers/api/shipments_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/shipments_controller.rb b/app/controllers/api/shipments_controller.rb index 99f03bef7aaa..69f4b7d037a9 100644 --- a/app/controllers/api/shipments_controller.rb +++ b/app/controllers/api/shipments_controller.rb @@ -30,7 +30,7 @@ def update @shipment.adjustment.open end - @shipment.update(params[:shipment]) + @shipment.update(shipment_params[:shipment]) if unlock == 'yes' @shipment.adjustment.close @@ -88,7 +88,7 @@ def find_order def find_and_update_shipment @shipment = @order.shipments.find_by!(number: params[:id]) - @shipment.update(params[:shipment]) + @shipment.update(shipment_params[:shipment]) if shipment_params[:shipment].present? @shipment.reload end @@ -101,5 +101,12 @@ def scoped_variant(variant_id) def get_or_create_shipment(stock_location_id) @order.shipment || @order.shipments.create(stock_location_id: stock_location_id) end + + def shipment_params + params.permit( + [:id, :order_id, :variant_id, :quantity, + { shipment: [:tracking, :selected_shipping_rate_id] }] + ) + end end end