Update void payments to checkout on resumed order

This commit is contained in:
Ana Nunes da Silva
2023-02-06 11:37:30 +00:00
parent c9e6d24eb0
commit f4980fa84d
2 changed files with 26 additions and 0 deletions

View File

@@ -673,6 +673,8 @@ module Spree
def after_resume
shipments.each(&:resume!)
payments.void.each(&:resume!)
update(payment_state: updater.update_payment_state)
end

View File

@@ -326,6 +326,30 @@ describe Spree::Order do
end
end
describe "#resume" do
let(:order) { create(:order_with_totals_and_distribution, :completed) }
before do
order.cancel!
order.resume!
end
it "should resume the order" do
expect(order.state).to eq 'resumed'
end
it "should resume the shipments" do
expect(order.shipments.pluck(:state)).to eq ['pending']
end
context "when payment is in void state" do
it "should change the state of the payment to checkout" do
order.payments.reload
expect(order.payments.pluck(:state)).to eq ['checkout']
end
end
end
context "insufficient_stock_lines" do
let(:line_item) { build(:line_item) }