Surface admin form errors and publish an arrival window - #143
Merged
Merged
Conversation
A failed admin create re-rendered the form with a 422, but log_admin_action then raised on the unsaved record (AuditLog needs a record_id) and re-raised in development, so Rails swapped the form for an exception page carrying turbo-visit-control: reload — the admin saw a silently reset form and no error at all. Skip the audit log when the record was never persisted. The support email field now also validates live against Event::SUPPORT_EMAIL_DOMAINS, so an address outside Hack Club's domains is flagged as it is typed instead of on submit. Events gain an optional arrival window (arrival_opens_at / arrival_closes_at), editable from the setup wizard and event settings and shown to attendees as "when to arrive" on their dashboard in place of the "not published" fallback. Also fixes a 500 on support change requests: Parameters#fetch wraps a Hash default in a fresh unpermitted Parameters, which raised on #to_h whenever a request carried no field changes.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Entering a support email outside
@hackclub.com/@events.hackclub.comon the new-event form looked like nothing happened: no error, just a reset form. The 422 re-render was correct — butlog_admin_action(anafter_actionon every non-GET admin request) then raised, because on a failed create the only record it can find is the unsaved event andAuditLogrequires arecord_id. The rescue re-raises in dev/test, so Rails replaced the form with its exception page, which carries<meta name="turbo-visit-control" content="reload">, and Turbo full-reloaded back to a blank form. This affected every admin create that fails validation, not just this field.While in the area, events can now publish an arrival window, and a 500 on support change requests is fixed.
What changed
Admin form errors survive again
log_admin_actionskips records that were never persisted (record.id.blank?).find_changed_record: without that, the freshly-created signed-in user in request specs carriesprevious_changesand becomes the audit record, hiding the bug — which is why the existing 422 spec passed throughout.Live support-email validation
email-domainStimulus controller: flags a disallowed domain as it is typed, on the create form and event settings. Domains come fromEvent::SUPPORT_EMAIL_DOMAINS, andsetCustomValidityblocks the submit, so the server validation stays the source of truth.Arrival window
arrival_opens_at/arrival_closes_aton events, editable in the setup wizard's schedule step and in event settings, interpreted in the event's timezone like the other schedule fields.docs/openapi.ymlupdated,mint validatepasses) and the MCP events toolbox.Support change requests no longer 500
Parameters#fetch(:requested_changes, {})wraps the Hash default in a fresh unpermittedParameters, which raisesUnfilteredParameterson#to_h. A support request sends no field changes, so every one of them hit it.Testing
bundle exec rspec spec/models/event_spec.rb spec/requests/admin/event_setup_spec.rb spec/requests/registration_corrections_spec.rb spec/requests/registration_completion_states_spec.rb spec/toolboxes— 115 examples, 0 failuresnode --test spec/javascript/email_domain_controller_test.mjs— 4 passingbundle exec rubocopcleanNot yet given a visual pass in light/dark or on mobile.