Update tax charging in checkout flow

This commit is contained in:
Matt-Yorkley
2021-02-20 11:53:57 +00:00
parent 2ab9602ad7
commit ac67f7391e
2 changed files with 5 additions and 7 deletions

View File

@@ -77,9 +77,9 @@ module Spree
before_transition to: :delivery, do: :create_proposed_shipments
before_transition to: :delivery, do: :ensure_available_shipping_rates
before_transition to: :payment, do: :create_tax_charge!
after_transition to: :complete, do: :finalize!
after_transition to: :delivery, do: :create_tax_charge!
after_transition to: :resumed, do: :after_resume
after_transition to: :canceled, do: :after_cancel
after_transition to: :payment, do: :charge_shipping_and_payment_fees!

View File

@@ -48,16 +48,14 @@ describe Spree::Order do
end
end
context "when current state is address" do
context "when current state is delivery" do
before do
allow(order).to receive(:ensure_available_shipping_rates)
order.state = "address"
order.state = "delivery"
end
it "adjusts tax rates when transitioning to delivery" do
# Once because the record is being saved
# Twice because it is transitioning to the delivery state
expect(Spree::TaxRate).to receive(:adjust).twice
it "adjusts tax rates when transitioning to payment" do
expect(Spree::TaxRate).to receive(:adjust)
order.next!
end
end