Merge pull request #2767 from luisramos0/order_empty

[Spree Upgrade] Destroy all shipments when clearing order
This commit is contained in:
Pau Pérez Fabregat
2018-09-26 08:54:11 +02:00
committed by GitHub
2 changed files with 5 additions and 5 deletions

View File

@@ -87,7 +87,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

View File

@@ -387,18 +387,18 @@ describe Spree::Order do
end
describe "emptying the order" do
it "removes shipping method" do
subject.shipments = [create(:shipment)]
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