mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
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 commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -500,7 +500,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 []
|
||||
expect(line_items.map(&:quantity)).to eq [0]
|
||||
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, only 5 remaining"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user