mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Removing payments when emptying order
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user