Skip to content

Commit

Permalink
Merge pull request #2767 from luisramos0/order_empty
Browse files Browse the repository at this point in the history
[Spree Upgrade] Destroy all shipments when clearing order
  • Loading branch information
sauloperez authored Sep 26, 2018
2 parents 267edbd + eb64569 commit 037432d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/spree/order_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def disallow_guest_order
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

Expand Down
8 changes: 4 additions & 4 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,18 @@
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

Expand Down

0 comments on commit 037432d

Please sign in to comment.