refactor: consolidate duplicate clear_member_cache callback into InvitationConcerns#2699
Merged
Merged
Conversation
…tationConcerns The same after_save callback + private method was duplicated across Invitation, WorkshopInvitation, and MeetingInvitation. All three already include InvitationConcerns, so move the callback there. Score 2/5 per the layered-architecture callback rubric (pure side effect — cache busting). Acceptable in a concern shared by all three models rather than extracting a separate service, keeping the fix minimal.
…t individual test The cache-invalidation test was only in invitation_spec.rb, leaving WorkshopInvitation and MeetingInvitation untested for the same callback. Add the test to the behaves_like_an_invitation shared example so all three models are covered. Remove the now-redundant test from invitation_spec.rb -- the shared example runs it for Invitation too. The member_spec tests for attending_event_ids caching and clear_attending_event_ids_cache! remain unchanged -- they verify the member-side contract rather than the callback trigger.
b3709bb to
5d193c7
Compare
KimberleyCook
approved these changes
Jul 10, 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.
What
Consolidate a duplicated
after_save :clear_member_cachecallback + private method found in 3 models into the sharedInvitationConcernsmodule.Why
Identified in the layered-architecture analysis. The same callback (score 2/5 — pure side-effect cache busting) was copy-pasted across
Invitation,WorkshopInvitation, andMeetingInvitation. All three already includeInvitationConcerns, so this is the natural home for it.Moving it to the concern eliminates 24 lines of duplication with zero new abstractions.
Changes
Commit 1 —
fe83aaa2— Move callback + method to concern:after_save :clear_member_cache, if: :saved_change_to_attending?toInvitationConcernsclear_member_cacheprivate method from all 3 modelsCommit 2 —
5d193c79— Fix test gap:behaves_like_an_invitationshared example so all 3 models are covered (WorkshopInvitation and MeetingInvitation had no cache test previously)invitation_spec.rbVerification