Removing payments when emptying order

This commit is contained in:
Will Marshall
2014-06-10 11:15:04 +10:00
parent dbf4f503a9
commit 4d7fa8b1bf
2 changed files with 11 additions and 3 deletions

View File

@@ -76,11 +76,12 @@ Spree::Order.class_eval do
end
end
def empty_with_clear_shipping!
empty_without_clear_shipping!
def empty_with_clear_shipping_and_payments!
empty_without_clear_shipping_and_payments!
payments.clear
update_attributes(shipping_method_id: nil)
end
alias_method_chain :empty!, :clear_shipping
alias_method_chain :empty!, :clear_shipping_and_payments
def set_order_cycle!(order_cycle)
unless self.order_cycle == order_cycle

View File

@@ -218,6 +218,13 @@ describe Spree::Order do
subject.empty!
subject.shipping_method.should == nil
end
it "removes payments" do
subject.payments << create(:payment)
subject.save!
subject.empty!
subject.payments.should == []
end
end
describe "setting the order cycle" do