From 306390440a59137bf3dca4fa6eb9ddd6af86fce2 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Tue, 16 Jul 2019 11:00:21 +0100 Subject: [PATCH] Revert "Swith line_item_syncer.create_new_items from deleting line item in the case of stock issue, to simply set the quantity to zero. This makes things easier later as the line item is already present if the user tries to change quantity of the subscription_line_item" This reverts commit d153e58933657ab290f07164ab062ec0e50df70e. --- app/services/line_item_syncer.rb | 2 +- spec/services/order_syncer_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/services/line_item_syncer.rb b/app/services/line_item_syncer.rb index bd43827e29..5c304557e7 100644 --- a/app/services/line_item_syncer.rb +++ b/app/services/line_item_syncer.rb @@ -35,8 +35,8 @@ class LineItemSyncer skip_stock_check: skip_stock_check?(order)) next if skip_stock_check?(order) || new_line_item.sufficient_stock? + order.line_items.delete(new_line_item) add_order_update_issue(order, new_line_item) - new_line_item.update_attributes(quantity: 0) end end diff --git a/spec/services/order_syncer_spec.rb b/spec/services/order_syncer_spec.rb index 67d7937467..10c8020162 100644 --- a/spec/services/order_syncer_spec.rb +++ b/spec/services/order_syncer_spec.rb @@ -510,7 +510,7 @@ describe OrderSyncer do expect(syncer.sync!).to be true line_items = Spree::LineItem.where(order_id: subscription.orders, variant_id: variant.id) - expect(line_items.map(&:quantity)).to eq [0] + expect(line_items.map(&:quantity)).to eq [] expect(order.reload.total.to_f).to eq 59.97 expect(syncer.order_update_issues[order.id]).to include "#{variant.product.name} - #{variant.full_name} - Insufficient stock available" end