Skip to content

Commit

Permalink
Destroy all shipments when clearing order
Browse files Browse the repository at this point in the history
Now we only clear the order's shipping_method, and in Spree 2.0 it can
have many shipments.
  • Loading branch information
sauloperez committed Jul 1, 2017
1 parent 05aeb03 commit 8ae36c9
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 @@ -83,7 +83,7 @@ def products_available_from_new_distribution
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 @@ -383,18 +383,18 @@
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

Expand Down

0 comments on commit 8ae36c9

Please sign in to comment.