Update void payments

Backport from Spree 2.4 stable: 4121992398
This commit is contained in:
Matt-Yorkley
2021-04-25 22:47:45 +01:00
parent 13bb5aa8dd
commit 135a311c05
2 changed files with 10 additions and 1 deletions

View File

@@ -201,7 +201,7 @@ module Spree
end
def update_order
if completed?
if completed? || void?
order.updater.update_payment_total
end

View File

@@ -546,6 +546,15 @@ describe Spree::Payment do
end
end
context 'when the payment was completed but now void' do
let(:payment) { create(:payment, amount: 100, order: order, state: 'completed') }
it 'updates order payment total' do
payment.void
expect(order.payment_total).to eq 0
end
end
context "completed orders" do
before { allow(order).to receive(:completed?) { true } }