mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-25 05:45:15 +00:00
Adding deleted_at check on variant_stock move
This commit is contained in:
@@ -106,10 +106,10 @@ module VariantStock
|
||||
#
|
||||
# This enables us to override this behaviour for variant overrides
|
||||
def move(quantity, originator = nil)
|
||||
raise_error_if_no_stock_item_available
|
||||
# Don't change variant stock if variant is on_demand or has been deleted
|
||||
return if on_demand || deleted_at
|
||||
|
||||
# Don't change variant stock if variant is on_demand
|
||||
return if on_demand
|
||||
raise_error_if_no_stock_item_available
|
||||
|
||||
# Creates a stock movement: it updates stock_item.count_on_hand and fills backorders
|
||||
#
|
||||
|
||||
@@ -283,6 +283,13 @@ describe Spree::Order do
|
||||
order.completed_at = Time.zone.now
|
||||
expect(order.can_cancel?).to be_truthy
|
||||
end
|
||||
|
||||
it "should cancel order if product is soft deleted" do
|
||||
o = FactoryBot.create(:completed_order_with_totals)
|
||||
o.line_items.first.variant.product.tap(&:destroy)
|
||||
o.cancel!
|
||||
expect(Spree::Order.by_state(:canceled)).to include o
|
||||
end
|
||||
end
|
||||
|
||||
context "insufficient_stock_lines" do
|
||||
|
||||
Reference in New Issue
Block a user