diff --git a/api/app/controllers/spree/api/orders_controller.rb b/api/app/controllers/spree/api/orders_controller.rb index 732c94a2228..0d4afeb4d45 100644 --- a/api/app/controllers/spree/api/orders_controller.rb +++ b/api/app/controllers/spree/api/orders_controller.rb @@ -46,7 +46,9 @@ def create def empty authorize! :update, @order, order_token - @order.empty! + + @order.empty! unless @order.shipped? + respond_with(@order, default_template: :show) end diff --git a/backend/spec/features/admin/orders/order_details_spec.rb b/backend/spec/features/admin/orders/order_details_spec.rb index 459a4c5e94c..522009f869b 100644 --- a/backend/spec/features/admin/orders/order_details_spec.rb +++ b/backend/spec/features/admin/orders/order_details_spec.rb @@ -399,6 +399,33 @@ expect(page).not_to have_selector('.fa-arrows-h') expect(page).not_to have_selector('.fa-trash') end + + context 'and on the cart page the cart is emptied' do + it 'should show the empty cart page' do + order = create(:order_ready_to_ship) + + visit spree.cart_admin_order_path(order) + order.fulfill! + + ## simulate shipping order in another tab + shipment = order.shipments.first + order.shipping.ship( + inventory_units: shipment.inventory_units, + stock_location: shipment.stock_location, + address: order.ship_address, + shipping_method: shipment.shipping_method + ) + + click_on 'Empty Cart' + + accept_alert 'Are you sure you want to delete this record?' do + click_icon :ok + end + + expect(page.current_path).to eq(spree.cart_admin_order_path(order)) + expect(page).not_to have_content(order.line_items.first.variant.sku) + end + end end end