Rename #charge_shipping_and_payment_fees! to #set_payment_amount!

This method sets the order's payment amount during the checkout. It doesn't really have anything to do with shipping or payment fees...
This commit is contained in:
Matt-Yorkley
2021-04-03 16:14:38 +01:00
parent a01493725d
commit 2d647be8b4
3 changed files with 5 additions and 5 deletions

View File

@@ -788,7 +788,7 @@ module Spree
# before the shipping method is set. This results in the customer not being
# charged for their order's shipping. To fix this, we refresh the payment
# amount here.
def charge_shipping_and_payment_fees!
def set_payment_amount!
update_totals
return unless pending_payments.any?

View File

@@ -82,7 +82,7 @@ module Spree
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!
after_transition to: :payment, do: :set_payment_amount!
end
end

View File

@@ -1268,7 +1268,7 @@ describe Spree::Order do
end
end
describe '#charge_shipping_and_payment_fees!' do
describe '#set_payment_amount!' do
let(:order) do
shipment = build(:shipment_with, :shipping_method, shipping_method: build(:shipping_method))
build(:order, shipments: [shipment] )
@@ -1281,8 +1281,8 @@ describe Spree::Order do
allow(order).to receive(:payment_required?) { true }
end
it 'calls charge_shipping_and_payment_fees! and updates totals' do
expect(order).to receive(:charge_shipping_and_payment_fees!)
it 'calls #set_payment_amount! and updates totals' do
expect(order).to receive(:set_payment_amount!)
expect(order).to receive(:update_totals).at_least(:once)
order.next