mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Destroy all shipments when clearing order
Now we only clear the order's shipping_method, and in Spree 2.0 it can have many shipments.
This commit is contained in:
@@ -83,7 +83,7 @@ Spree::Order.class_eval do
|
||||
def empty_with_clear_shipping_and_payments!
|
||||
empty_without_clear_shipping_and_payments!
|
||||
payments.clear
|
||||
update_attributes(shipping_method_id: nil)
|
||||
shipments.destroy_all
|
||||
end
|
||||
alias_method_chain :empty!, :clear_shipping_and_payments
|
||||
|
||||
|
||||
@@ -383,18 +383,18 @@ describe Spree::Order do
|
||||
end
|
||||
|
||||
describe "emptying the order" do
|
||||
it "removes shipping method" do
|
||||
subject.shipping_method = create(:shipping_method)
|
||||
it "removes shipments" do
|
||||
subject.shipments << create(:shipment)
|
||||
subject.save!
|
||||
subject.empty!
|
||||
subject.shipping_method.should == nil
|
||||
expect(subject.shipments).to be_empty
|
||||
end
|
||||
|
||||
it "removes payments" do
|
||||
subject.payments << create(:payment)
|
||||
subject.save!
|
||||
subject.empty!
|
||||
subject.payments.should == []
|
||||
expect(subject.payments).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user