Merge pull request #6982 from andrewpbrett/canceled-order-payments

Fix #5018: Allow access to payments tab for canceled orders
This commit is contained in:
Pau Pérez Fabregat
2021-03-04 17:25:30 +01:00
committed by GitHub
2 changed files with 23 additions and 2 deletions

View File

@@ -130,11 +130,11 @@ module Spree
# At this point admin should have passed through Customer Details step
# where order.next is called which leaves the order in payment step
#
# Orders in complete step also allows to access this controller
# Orders in complete or canceled step also allows to access this controller
#
# Otherwise redirect user to that step
def can_transition_to_payment
return if @order.payment? || @order.complete?
return if @order.payment? || @order.complete? || @order.canceled?
flash[:notice] = Spree.t(:fill_in_customer_info)
redirect_to spree.edit_admin_order_customer_url(@order)

View File

@@ -278,4 +278,25 @@ describe Spree::Admin::PaymentsController, type: :controller do
end
end
end
describe '#index' do
context "order is canceled but has a completed payment" do
let(:payment_method) do
create(
:stripe_sca_payment_method,
distributor_ids: [create(:distributor_enterprise).id],
preferred_enterprise_id: create(:enterprise).id
)
end
let!(:order) { create(:order, state: 'canceled') }
let!(:payment) do
create(:payment, order: order, payment_method: payment_method, amount: order.total)
end
it "renders the payments tab" do
spree_get :index, order_id: order.number
expect(response.status).to eq 200
end
end
end
end