diff options
-rw-r--r-- | app/models/solidus_subscriptions/checkout.rb | 13 | ||||
-rw-r--r-- | spec/models/solidus_subscriptions/checkout_spec.rb | 19 |
2 files changed, 24 insertions, 8 deletions
diff --git a/app/models/solidus_subscriptions/checkout.rb b/app/models/solidus_subscriptions/checkout.rb index 22882b7..e5f634c 100644 --- a/app/models/solidus_subscriptions/checkout.rb +++ b/app/models/solidus_subscriptions/checkout.rb @@ -68,14 +68,11 @@ module SolidusSubscriptions order.update! apply_promotions - order.next! # cart => address - - order.ship_address = ship_address - order.next! # address => delivery - order.next! # delivery => payment - - create_payment - order.next! # payment => confirm + order.checkout_steps[0...-1].each do |step| + order.ship_address = ship_address if order.state == :address + create_payment if order.state == :payment + order.next! + end # Do this as a separate "quiet" transition so that it returns true or # false rather than raising a failed transition error diff --git a/spec/models/solidus_subscriptions/checkout_spec.rb b/spec/models/solidus_subscriptions/checkout_spec.rb index 4a156e1..49c6dc6 100644 --- a/spec/models/solidus_subscriptions/checkout_spec.rb +++ b/spec/models/solidus_subscriptions/checkout_spec.rb @@ -105,6 +105,25 @@ RSpec.describe SolidusSubscriptions::Checkout do end end + context 'Altered checkout flow' do + before do + Spree::Order.remove_checkout_step(:delivery) + end + + it 'has a payment' do + expect(order.payments.valid).to be_present + end + + it 'has the correct totals' do + expect(order).to have_attributes( + total: 39.98, + shipment_total: 0 + ) + end + + it { is_expected.to be_complete } + end + context 'the variant is out of stock' do let(:subscription_line_item) { installments.last.subscription.line_items.first } |