Skip to content

Move the OmniAuth callbacks controller spec into a request spec - #1302

Merged
amatsuda merged 1 commit into
rubycentral:mainfrom
amatsuda:omniauth_request_spec
Nov 19, 2026
Merged

amatsuda merged 1 commit into
rubycentral:mainfrom
amatsuda:omniauth_request_spec

Conversation

@amatsuda

@amatsuda amatsuda commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

spec/controllers/users/omniauth_callbacks_controller_spec.rb (7 examples) becomes spec/requests/omniauth_callbacks_spec.rb. Provider callbacks are HTTP plumbing with no page of their own, so this is the one group that goes to request specs rather than system specs.

OmniAuth already runs in test mode for the suite, so requesting a provider's callback path directly hands the controller that provider's mock auth hash. That removes the request.env['omniauth.auth'] and reload_routes_unless_loaded workarounds the controller spec needed, and the current_user stub.

Behaviour covered is unchanged:

  • a first sign-in via Twitter creates the account and its identity, and lands on the profile page because Twitter provides no email
  • an existing user is found through their identity, or through the legacy provider/uid columns, and gets a session
  • a signed-in user connecting GitHub is linked; is told when it is already linked; is refused when the GitHub account belongs to someone else; is sent to the merge page when a legacy account used it, with the pending-merge session keys set

Test

Full suite locally: 695 examples, 0 failures.

🤖 Generated with Claude Code

Provider callbacks are HTTP plumbing with no page of their own, so the
seven examples become request specs. OmniAuth's test mode hands the
controller the mocked auth hash when the callback path is requested
directly, which removes the request.env and reload_routes workarounds
the controller spec needed. The behaviour checked is unchanged: first
sign-in via Twitter creates the account and identity, existing users are
found by identity or by the legacy provider/uid columns, and a signed-in
user connecting GitHub is linked, told it is already linked, refused when
it belongs to someone else, or sent to the merge page for a legacy
account.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@amatsuda
amatsuda merged commit 1a2fd70 into rubycentral:main Nov 19, 2026
2 checks passed
@amatsuda
amatsuda deleted the omniauth_request_spec branch November 19, 2026 06:01
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.

1 participant