Rename public_registration to public_forms with variant-aware routing#1599
Rename public_registration to public_forms with variant-aware routing#1599maebeale wants to merge 2 commits into
Conversation
The single public_registration resource conflated three distinct public-facing flows (registration, scholarship application, bulk payment). Splitting it into registration_form/scholarship_form/ bulk_payment_form resources that share one PublicFormsController lets each flow have its own URL while a form_variant default drives the heading, paths, and scholarship behavior — making the variant explicit in the URL instead of inferred from query params alone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
|
||
| def form_variant | ||
| VARIANTS.include?(params[:form_variant]) ? params[:form_variant] : "registration" | ||
| end |
There was a problem hiding this comment.
🤖 From Claude: form_variant is whitelisted against VARIANTS and falls back to "registration", so an unknown variant in the URL degrades to the default flow rather than blowing up the path helpers below.
| params[:scholarship_requested] != "false" | ||
| else | ||
| params[:scholarship_requested] == "true" | ||
| end |
There was a problem hiding this comment.
🤖 From Claude: Scholarship default differs by variant: the scholarship_form flow opts in unless scholarship_requested=false, while other flows opt in only when explicitly =true. This preserves the existing query-param behavior for the registration flow.
| @@ -130,7 +130,15 @@ | |||
| post :send_reminder | |||
| end | |||
| resource :registrations, only: %i[ create destroy ], module: :events, as: :registrant_registration | |||
There was a problem hiding this comment.
🤖 From Claude: The registrant_registration resource stays separate from the three new public *_form resources — the routing spec asserts POST /events/:id/registrations still hits events/registrations#create and does not collide.
Add bulk_payment and ce_credit as event-form roles and drive the public form endpoints, controller variant whitelist, and Event#*_form accessors off EventForm::ROLES so the role list lives in exactly one place. Routes and per-role scopes/accessors are now generated from ROLES, and the controller's "form_variant" concept is renamed to "form_role" to match the model's vocabulary. No behavior change to the existing registration and scholarship flows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
What is the goal of this PR and why is this important?
public_registrationresource conflated three distinct public-facing flows: registration, scholarship application, and bulk paymentregistration_form,scholarship_form,bulk_payment_form) instead of being inferred from query params alone, making the variant visible in the URL and shareableHow did you approach the change?
Events::PublicRegistrationsController→Events::PublicFormsControllerand the matching policy/views/specspublic_registrationroute with three singular resources that share thepublic_formscontroller, each passing aform_variantdefault (registration/scholarship/bulk_payment)form_variantdrives the page heading, the new/submit path helpers, and scholarship mode, so one controller serves all three flowsrender/link_toreferences fromevents/public_registrations/*toevents/public_forms/*spec/routing/public_forms_routing_spec.rbcovering each variant's new/create/show routes and confirming no collision with the registrantregistrationsrouteAnything else to add?
ai/lintclean, routing + registrations + scholarships request specs green (56 examples, 0 failures)🤖 Generated with Claude Code