Skip to content

refactor: consolidate duplicate clear_member_cache callback into InvitationConcerns#2699

Merged
mroderick merged 3 commits into
masterfrom
feature/consolidate-member-cache-callback
Jul 10, 2026
Merged

refactor: consolidate duplicate clear_member_cache callback into InvitationConcerns#2699
mroderick merged 3 commits into
masterfrom
feature/consolidate-member-cache-callback

Conversation

@mroderick

@mroderick mroderick commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

What

Consolidate a duplicated after_save :clear_member_cache callback + private method found in 3 models into the shared InvitationConcerns module.

Why

Identified in the layered-architecture analysis. The same callback (score 2/5 — pure side-effect cache busting) was copy-pasted across Invitation, WorkshopInvitation, and MeetingInvitation. All three already include InvitationConcerns, 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:

  • Add after_save :clear_member_cache, if: :saved_change_to_attending? to InvitationConcerns
  • Remove identical callback + clear_member_cache private method from all 3 models

Commit 2 — 5d193c79 — Fix test gap:

  • Add cache-invalidation test to the behaves_like_an_invitation shared example so all 3 models are covered (WorkshopInvitation and MeetingInvitation had no cache test previously)
  • Remove the now-redundant identical test from invitation_spec.rb

Verification

  • All 110 related examples pass (invitation specs, member specs, member presenter specs)
  • Test coverage now uniform across all 3 invitation model types

…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.
@mroderick mroderick force-pushed the feature/consolidate-member-cache-callback branch from b3709bb to 5d193c7 Compare July 10, 2026 06:58
@mroderick mroderick marked this pull request as ready for review July 10, 2026 06:59
@mroderick mroderick requested a review from olleolleolle July 10, 2026 06:59
@mroderick mroderick enabled auto-merge July 10, 2026 09:27
@mroderick mroderick merged commit 45852fd into master Jul 10, 2026
8 checks passed
@mroderick mroderick deleted the feature/consolidate-member-cache-callback branch July 10, 2026 09:31
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.

2 participants