Skip to content

Post a public survey back to the validated event, not the raw param - #2968

Merged
maebeale merged 1 commit into
mainfrom
tidy-public-survey-links
Nov 8, 2026
Merged

maebeale merged 1 commit into
mainfrom
tidy-public-survey-links

Conversation

@maebeale

@maebeale maebeale commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Two loose ends from the #2768 review, neither visible to a respondent today. No behavior change for a correct link.

1. The public survey views read raw params

public_forms/show.html.erb and thank_you.html.erb built the form action, a hidden field and the "Submit another response" link from params[:event] / params[:event_id] directly — so an id PublicFormsController#set_event had already rejected (a deleted event, an event whose kind doesn't offer that survey, a typo) was echoed straight back into the page and rode along through the next submission to be rejected again.

Read the validated @event instead. Two side benefits: the ?event_id= alias normalizes to the canonical ?event=, and one hidden field does the job of two.

2. "Live form" could point at an unrelated form

form_live_view_link sent "Live form" to the event's public registration page for any form that isn't publicly fillable. That's right for the event-connected form the link was written for, but since #2768 a survey form reaches the editor with an event it is merely allowed for (FormsController#set_dashboard_event) — and that event's registration form belongs to somebody else. An unpublished survey plus an event_id pointed the admin at an unrelated form.

Offer that path only when the form is connected to the event, which is the invariant set_dashboard_event used to guarantee on its own. Reachable only by a hand-built URL today, so this is a guard rather than a fix for anything staff have hit.

Untouched, pre-existing: a connected scholarship or CE form's editor still links to the plain registration page rather than its own variant.

Changes

  • app/views/public_forms/show.html.erb, app/views/public_forms/thank_you.html.erb, app/helpers/forms_helper.rb
  • Specs: the event_id alias normalizes to event; a disallowed event is absent from both the action and the posted field; the live link is nil for a form neither publicly fillable nor connected to the event. One existing helper example now connects its form to the event — the case that branch was written for.

Testing

spec/helpers/forms_helper_spec.rb, spec/requests/public_forms_spec.rb, spec/requests/forms_spec.rb — 224 examples, 0 failures. Rubocop clean.

🤖 Generated with Claude Code

Two loose ends in the event-scoped survey link (#2768), neither of them
visible to a respondent today.

The public form page and its thank-you page read params[:event] /
params[:event_id] directly, so an id the controller had already rejected
— a deleted event, an event whose kind doesn't offer that survey, a
typo — was echoed back into the form action, a hidden field, and the
"Submit another response" link, where it rode along through the next
submission to be rejected again. Read @event instead, which
PublicFormsController#set_event has already validated, so the ?event_id=
alias also normalizes to the canonical ?event= and only one hidden field
is needed.

form_live_view_link sent "Live form" to the event's public registration
page for any form that isn't publicly fillable. That holds for the
event-connected form the link was written for, but a survey form now
reaches the editor with an event it is merely allowed for, whose
registration form belongs to somebody else — an unpublished survey plus
an event_id pointed the admin at an unrelated form. Offer that path only
when the form is connected to the event.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@maebeale
maebeale merged commit 6da8b8c into main Nov 8, 2026
3 checks passed
@maebeale
maebeale deleted the tidy-public-survey-links branch November 8, 2026 23:22
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