fix: prevent duplicate waiting list entries#2482
Open
mroderick wants to merge 8 commits intocodebar:masterfrom
Open
fix: prevent duplicate waiting list entries#2482mroderick wants to merge 8 commits intocodebar:masterfrom
mroderick wants to merge 8 commits intocodebar:masterfrom
Conversation
Design addresses issue codebar#2479 by: - Making WaitingList.add() idempotent with find_or_create_by - Adding unique database constraint on invitation_id - Cleaning up existing duplicates in migration
Prevents accidental commit of worktree directories
- Remove hard-coded line numbers - Make controller test more comprehensive (check responses and flash messages) - Improve migration safety (logging, delete_all, verification step) - Combine test and linting verification into single task - Make manual verification required instead of optional - Add production deployment and rollback notes
Use find_or_create_by instead of create to prevent duplicate waiting list entries for the same invitation. First call wins for auto_rsvp setting. Refs codebar#2479
Add comprehensive test to verify double-submission protection at the controller level. Test confirms that multiple identical POST requests result in only a single waiting list entry.
Migration cleans up existing duplicates (keeping oldest entry) before adding unique index to prevent future duplicates. Refs codebar#2479
- Use described_class instead of WaitingList class name - Use describe instead of context for method testing - Replace .times.map with Array.new pattern - Use Array#new with block instead of times.map - Remove useless variable assignment - Use `be` matcher instead of `eq` for boolean - Fix trailing whitespace
Contributor
KimberleyCook
left a comment
There was a problem hiding this comment.
Nice, thank you so much
KimberleyCook
approved these changes
Feb 11, 2026
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.
Summary
Fixes #2479 - Prevents duplicate waiting list entries by making
WaitingList.add()idempotent and adding a database-level unique constraint.Changes:
WaitingList.add()idempotent usingfind_or_create_by(first call wins forauto_rsvp)waiting_lists.invitation_idRoot cause: The controller action is not idempotent - double-clicks, browser back button, or network retries could create duplicate waiting list entries for the same invitation.
Solution approach:
find_or_create_bymakes the model method idempotentTest Plan
auto_rsvppreservation (first call wins)Coverage