Use env helper in Stripe provider tests

Agent-Logs-Url: https://github.com/we-promise/sure/sessions/a5dee415-c4db-4b62-b0f3-deacb6c650ce

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-04 17:28:31 +00:00
committed by GitHub
parent d36103dc6c
commit 6e5ae842d6

View File

@@ -67,24 +67,18 @@ class Provider::StripeTest < ActiveSupport::TestCase
.with(payment_link_id: "plink_test123")
.returns("https://buy.stripe.com/test_payment_link")
original_payment_link_id = ENV["STRIPE_PAYMENT_LINK_ID"]
ENV["STRIPE_PAYMENT_LINK_ID"] = "plink_test123"
assert_equal "https://buy.stripe.com/test_payment_link", stripe.one_time_contribution_url
ensure
ENV["STRIPE_PAYMENT_LINK_ID"] = original_payment_link_id
with_env_overrides("STRIPE_PAYMENT_LINK_ID" => "plink_test123") do
assert_equal "https://buy.stripe.com/test_payment_link", stripe.one_time_contribution_url
end
end
test "returns nil for one-time contribution url when payment link id is missing" do
stripe = Provider::Stripe.new(secret_key: "foo", webhook_secret: "bar")
stripe.expects(:payment_link_url).with(payment_link_id: nil).returns(nil)
original_payment_link_id = ENV["STRIPE_PAYMENT_LINK_ID"]
ENV.delete("STRIPE_PAYMENT_LINK_ID")
assert_nil stripe.one_time_contribution_url
ensure
ENV["STRIPE_PAYMENT_LINK_ID"] = original_payment_link_id
with_env_overrides("STRIPE_PAYMENT_LINK_ID" => nil) do
assert_nil stripe.one_time_contribution_url
end
end
test "returns nil when payment link retrieval fails" do