diff options
author | Sean <seand7565@gmail.com> | 2021-04-07 09:29:59 -0500 |
---|---|---|
committer | Sean <seand7565@gmail.com> | 2021-04-07 11:41:07 -0500 |
commit | 565e8f737146a51b160a3d00c2abd07bc932ca2d (patch) | |
tree | 83328c3b949822ebf7b1dac57497c196f3b23904 /spec | |
parent | 6a150092cdd35008d7ddeee4f8354ff4db088616 (diff) |
Reload order during finalize action
If you decorate the subscription generator to change the order
in any way (for instance, to associate the order to the
subscription), that change is not persisted in the rest of the
finalize action, as the order has already been loaded by that
point.
This can cause massive headaches with validations, so to fix it
I've added a reload method before super, so we can ensure that
the order is up-to-date before continuing.
This also means that subscription_line_items interval is nil,
since activating the subscription sets it to nil. So in the spec
we're fetching the interval from the subscription instead.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb index 121afbf..0ca34d9 100644 --- a/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb +++ b/spec/decorators/models/solidus_subscriptions/spree/order/finalize_creates_subscriptions_spec.rb @@ -8,7 +8,7 @@ RSpec.describe SolidusSubscriptions::Spree::Order::FinalizeCreatesSubscriptions let(:order) { create :order, :with_subscription_line_items } let(:subscription_line_item) { order.subscription_line_items.last } - let(:expected_actionable_date) { Time.zone.today + subscription_line_item.interval } + let(:expected_actionable_date) { Time.zone.today + subscription_line_item.subscription.interval } around { |e| Timecop.freeze { e.run } } |