Adding spec for case when standing_order_orders aren't linked to an order cycle

This should never happen, but came up in specs
This commit is contained in:
Rob Harrington
2016-12-07 11:24:27 +11:00
parent 284103b6b6
commit 076a05f8a9
2 changed files with 13 additions and 3 deletions

View File

@@ -17,10 +17,10 @@ class StandingOrderOrder < ActiveRecord::Base
end
def cancel
return false unless order.order_cycle.orders_close_at > Time.zone.now
return false unless order.order_cycle.andand.orders_close_at.andand > Time.zone.now
transaction do
self.update_column(:cancelled_at, Time.zone.now)
order.send('cancel') if order.complete?
order.send('cancel')
true
end
end