Skip to content

Fix registration_policy changes not captured in event changelog#11232

Merged
nbudin merged 1 commit intomainfrom
10998-fix-bucket-change-capture
Mar 19, 2026
Merged

Fix registration_policy changes not captured in event changelog#11232
nbudin merged 1 commit intomainfrom
10998-fix-bucket-change-capture

Conversation

@nbudin
Copy link
Contributor

@nbudin nbudin commented Mar 19, 2026

Summary

  • Fixes a bug where updating an event's registration policy via the UpdateEvent mutation would record the same value for both previous_value and new_value in the FormResponseChange changelog entry
  • The root cause: apply_registration_policy called event.reload after EventChangeRegistrationPolicyService, which overwrote the in-memory event with the saved new policy — so event.registration_policy was already the new policy when we tried to capture the old one
  • Fix: capture old_registration_policy = event.registration_policy before calling the service and reload

Test plan

  • Added test/graphql/mutations/update_event_test.rb with tests that verify:
    • A FormResponseChange is created for registration_policy changes
    • previous_value is the old policy, not the new one
    • new_value is the new policy
    • previous_value and new_value are different
    • Registration policy changes flow through to NotifyFormResponseChangesService
  • Added test/graphql/mutations/update_event_proposal_test.rb with tests that verify:
    • Proposal registration_policy changes are also captured correctly
    • Unchanged registration_policy does not create a spurious FormResponseChange

Fixes #10998

🤖 Generated with Claude Code

The `apply_registration_policy` method was calling `event.reload` after
`EventChangeRegistrationPolicyService`, causing `event.registration_policy`
to already reflect the new policy. As a result, both `previous_value` and
`new_value` in the FormResponseChange record were set to the new policy.

Fix by capturing `old_registration_policy` before calling the service and
reload. Also adds tests verifying correct previous/new values are stored
and that registration_policy changes flow through to the notification service.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nbudin nbudin added bug patch Bumps the patch version number on release labels Mar 19, 2026
@github-actions
Copy link
Contributor

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
app/graphql/mutations/base_mutation.rb 🟠 67.24% 🟢 75.86% 🟢 8.62%
app/graphql/mutations/update_event.rb 🔴 35.71% 🟢 100% 🟢 64.29%
app/graphql/mutations/update_event_proposal.rb 🔴 42.86% 🟢 100% 🟢 57.14%
app/models/concerns/form_response.rb 🟢 86.36% 🟢 93.18% 🟢 6.82%
app/models/form_item.rb 🟢 85.45% 🟢 90.91% 🟢 5.46%
app/policies/event_policy.rb 🟢 98.53% 🟢 100% 🟢 1.47%
app/policies/event_proposal_policy.rb 🟢 93.33% 🟢 100% 🟢 6.67%
app/services/compact_form_response_changes_service.rb 🔴 0% 🔴 46.15% 🟢 46.15%
app/services/notify_form_response_changes_service.rb 🔴 0% 🟢 100% 🟢 100%
test/graphql/mutations/update_event_proposal_test.rb 🔴 0% 🟢 100% 🟢 100%
test/graphql/mutations/update_event_test.rb 🔴 0% 🟢 100% 🟢 100%
Overall Coverage 🟢 52.75% 🟢 53.02% 🟢 0.27%

Minimum allowed coverage is 0%, this run produced 53.02%

@nbudin nbudin merged commit adf01d9 into main Mar 19, 2026
19 checks passed
@nbudin nbudin deleted the 10998-fix-bucket-change-capture branch March 19, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug patch Bumps the patch version number on release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal/Event Change Differ is not capturing bucket changes

1 participant