Skip to content

Fix broken #payment_intent spec in donations controller#13802

Merged
manuthecoder merged 1 commit into
mxg-improve-receipt-card-locking-requirementsfrom
claude/adoring-allen-qGyiO
May 26, 2026
Merged

Fix broken #payment_intent spec in donations controller#13802
manuthecoder merged 1 commit into
mxg-improve-receipt-card-locking-requirementsfrom
claude/adoring-allen-qGyiO

Conversation

@manuthecoder
Copy link
Copy Markdown
Contributor

The test added in #13705 had two bugs:

  1. create(:donation, in_person: true) triggers the before_create :create_stripe_payment_intent callback (recurring? is false), which calls StripeService::Customer.create and StripeService::PaymentIntent.create. WebMock is active in tests, so those unmocked HTTP calls raised WebMock::NetConnectNotAllowedError. Fix: add before { stub_donation_payment_intent_creation } so the Stripe calls are intercepted before the donation is created.

  2. The controller renders render json: {...} without a status: keyword, defaulting to HTTP 200. The test asserted have_http_status(:created) (201). Fix: assert :ok instead.

Also removed the spurious allow(StripeService::PaymentIntent).to receive(:create) stub placed after create(:donation) — the payment_intent action reads donation.stripe_payment_intent_id from the DB and never calls that method, so the mock had no effect and the hardcoded expected values were wrong.

https://claude.ai/code/session_01ANVXcC1VdckGJ2aYcaw3Ag

Summary of the problem

Describe your changes

The test added in #13705 had two bugs:

1. `create(:donation, in_person: true)` triggers the `before_create
   :create_stripe_payment_intent` callback (recurring? is false), which
   calls StripeService::Customer.create and StripeService::PaymentIntent.create.
   WebMock is active in tests, so those unmocked HTTP calls raised
   WebMock::NetConnectNotAllowedError. Fix: add `before { stub_donation_payment_intent_creation }`
   so the Stripe calls are intercepted before the donation is created.

2. The controller renders `render json: {...}` without a `status:` keyword,
   defaulting to HTTP 200. The test asserted `have_http_status(:created)` (201).
   Fix: assert `:ok` instead.

Also removed the spurious `allow(StripeService::PaymentIntent).to receive(:create)`
stub placed after `create(:donation)` — the `payment_intent` action reads
`donation.stripe_payment_intent_id` from the DB and never calls that method,
so the mock had no effect and the hardcoded expected values were wrong.

https://claude.ai/code/session_01ANVXcC1VdckGJ2aYcaw3Ag
@manuthecoder manuthecoder requested review from a team and Copilot May 26, 2026 20:30
@manuthecoder manuthecoder changed the base branch from main to mxg-improve-receipt-card-locking-requirements May 26, 2026 20:31
@manuthecoder manuthecoder merged commit 00d2e8f into mxg-improve-receipt-card-locking-requirements May 26, 2026
24 of 25 checks passed
@manuthecoder manuthecoder deleted the claude/adoring-allen-qGyiO branch May 26, 2026 20:31
@manuthecoder manuthecoder review requested due to automatic review settings May 26, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants