mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Remove variant from cart when it becomes out of stock
This commit is contained in:
@@ -60,6 +60,8 @@ Spree::OrderPopulator.class_eval do
|
||||
|
||||
if quantity_to_add > 0
|
||||
@order.add_variant(variant, quantity_to_add, max_quantity_to_add, currency)
|
||||
else
|
||||
@order.remove_variant variant
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -177,6 +177,19 @@ module Spree
|
||||
|
||||
op.attempt_cart_add(333, quantity.to_s, quantity.to_s)
|
||||
end
|
||||
|
||||
it "removes variants which have become out of stock" do
|
||||
op.should_receive(:quantities_to_add).with(variant, 123, 123).
|
||||
and_return([0, 0])
|
||||
|
||||
op.stub(:check_order_cycle_provided_for) { true }
|
||||
op.stub(:check_variant_available_under_distribution) { true }
|
||||
|
||||
order.should_receive(:remove_variant).with(variant)
|
||||
order.should_receive(:add_variant).never
|
||||
|
||||
op.attempt_cart_add(333, quantity.to_s, quantity.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
describe "quantities_to_add" do
|
||||
|
||||
Reference in New Issue
Block a user