Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows for subscription checkout to accommodate a more flexible checko… #15

Merged
merged 4 commits into from
Jul 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ begin

RSpec::Core::RakeTask.new(:spec)

task default: %i(first_run rubocop spec)
task default: %i(first_run spec)
rescue LoadError
# no rspec available
end
Expand Down
13 changes: 5 additions & 8 deletions app/models/solidus_subscriptions/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ def checkout
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
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
Expand Down
26 changes: 26 additions & 0 deletions spec/models/solidus_subscriptions/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,32 @@
end
end

if Gem::Specification.all.find{ |gem| gem.name == 'solidus' }.version >= Gem::Version.new('1.4.0')
context 'Altered checkout flow' do
before do
@old_checkout_flow = Spree::Order.checkout_flow
Spree::Order.remove_checkout_step(:delivery)
end

after do
Spree::Order.checkout_flow(&@old_checkout_flow)
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
end

context 'the variant is out of stock' do
let(:subscription_line_item) { installments.last.subscription.line_items.first }

Expand Down