Skip address setup logic if we're coming from Stripe

The code here runs from a callback which was originally designed to make sure the checkout page was set up correctly in the "normal" checkout workflow. It wasn't really designed to be run when the page is being loaded a second time due to the user being redirected back from Stripe (with SCA). The things it's doing here are necessary in the former case, but a really bad idea in the latter (potentially messing up the order's ship and bill addresses in certain cases like guest checkout).
This commit is contained in:
Matt-Yorkley
2021-11-14 14:33:31 +00:00
parent f83d0a766f
commit f8349434bf
2 changed files with 8 additions and 0 deletions

View File

@@ -210,6 +210,12 @@ describe CheckoutController, type: :controller do
expect(response).to redirect_to order_path(order)
end
it "does not attempt to load different addresses" do
expect(OpenFoodNetwork::AddressFinder).to_not receive(:new)
get :edit, params: { payment_intent: "pi_123" }
end
it "creates a customer record" do
order.update_columns(customer_id: nil)
Customer.delete_all