Files
openfoodnetwork/spec/routing/stripe_spec.rb
Maikel Linke 36c44a5487 Allow FeatureToggleConstraint to run w/o warden
Routing specs and controller specs don't set warden on the request
environment. While we could try to re-implement Warden/Devise logic
here, it's much easier to not rely on the environment to be set.

While I'm usually opposed to changing production code to make testing
easier, it does avoid a lot of complication in this case. And maybe it
would be handy in other circumstances to have a more defensive approach
to checking the logged in user.
2022-10-27 15:07:04 +11:00

43 lines
1.5 KiB
Ruby

# frozen_string_literal: true
require "spec_helper"
describe "routing for Stripe return URLS", type: :routing do
context "checkout return URLs" do
it "routes /checkout to checkout#edit" do
expect(get: "checkout").
to route_to("checkout#edit")
end
it "routes /checkout?test=123 to checkout#edit" do
expect(get: "/checkout?test=123").
to route_to(controller: "checkout", action: "edit", test: "123")
end
it "routes /checkout?payment_intent=pm_123 to payment_gateways/stripe#confirm" do
expect(get: "/checkout?payment_intent=pm_123").
to route_to(controller: "payment_gateways/stripe", action: "confirm", payment_intent: "pm_123")
end
end
context "authorization return URLs" do
let(:order) { create(:order) }
it "routes /orders/:number to spree/orders#show" do
expect(get: "orders/#{order.number}").
to route_to(controller: "spree/orders", action: "show", id: order.number)
end
it "routes /orders/:number?test=123 to spree/orders#show" do
expect(get: "/orders/#{order.number}?test=123").
to route_to(controller: "spree/orders", action: "show", id: order.number, test: "123")
end
it "routes /orders/:number?payment_intent=pm_123 to payment_gateways/stripe#authorize" do
expect(get: "/orders/#{order.number}?payment_intent=pm_123").
to route_to(controller: "payment_gateways/stripe", action: "authorize",
order_number: order.number, payment_intent: "pm_123")
end
end
end