Merge pull request #7110 from Matt-Yorkley/payment-capture-error

Fix payment capture handling in Api::OrdersController
This commit is contained in:
Andy Brett
2021-03-16 10:41:43 -07:00
committed by GitHub
2 changed files with 13 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ module Api
private
def payment_capture_failed
render json: { error: t(:payment_processing_failed) }, status: :unprocessable_entity
render json: { error: I18n.t(:payment_processing_failed) }, status: :unprocessable_entity
end
def serialized_orders(orders)

View File

@@ -285,6 +285,18 @@ module Api
expect(order.reload.pending_payments.empty?).to be true
expect_order
end
context "when payment is not required" do
before do
allow_any_instance_of(Spree::Order).to receive(:payment_required?) { false }
end
it "returns an error" do
put :capture, params: { id: order.number }
expect(json_response['error']).to eq I18n.t(:payment_processing_failed)
end
end
end
describe "#ship" do