mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Update: Untaken cash payments to void on cancelled order
This commit is contained in:
@@ -665,6 +665,7 @@ module Spree
|
||||
|
||||
def after_cancel
|
||||
shipments.each(&:cancel!)
|
||||
payments.checkout.each(&:void!)
|
||||
|
||||
OrderMailer.cancel_email(id).deliver_later if send_cancellation_email
|
||||
update(payment_state: updater.update_payment_state)
|
||||
|
||||
@@ -61,7 +61,7 @@ module OrderManagement
|
||||
expect(order.shipment_state).to be_nil
|
||||
end
|
||||
|
||||
["shipped", "ready", "pending"].each do |state|
|
||||
["shipped", "ready", "pending", "canceled"].each do |state|
|
||||
it "is #{state}" do
|
||||
allow(shipment).to receive(:state).and_return(state)
|
||||
updater.update_shipment_state
|
||||
|
||||
@@ -303,6 +303,29 @@ describe Spree::Order do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#cancel" do
|
||||
let(:order) { create(:order_with_totals_and_distribution, :completed) }
|
||||
|
||||
before { order.cancel! }
|
||||
|
||||
it "should cancel the order" do
|
||||
expect(order.state).to eq 'canceled'
|
||||
end
|
||||
|
||||
it "should cancel the shipments" do
|
||||
expect(order.shipments.pluck(:state)).to eq ['canceled']
|
||||
end
|
||||
|
||||
context "when payment has not been taken" do
|
||||
context "and payment is in checkout state" do
|
||||
it "should change the state of the payment to void" do
|
||||
order.payments.reload
|
||||
expect(order.payments.pluck(:state)).to eq ['void']
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "insufficient_stock_lines" do
|
||||
let(:line_item) { build(:line_item) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user