Skip to content

Commit a711288

Browse files
committed
Ensure cache invalidation happens
This fixes a number of places where the cache for the counts in the header weren't being invalidated meaning they would end up with the incorrect value. Jira-Issue: MAV-2004
1 parent 9a50dfe commit a711288

7 files changed

+29
-2
lines changed

app/controllers/consent_forms_controller.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def edit_match
3535
def update_match
3636
@consent_form.match_with_patient!(@patient, current_user:)
3737

38+
reset_count!
39+
3840
session =
3941
@patient
4042
.sessions
@@ -109,6 +111,8 @@ def create_patient
109111
school_move.confirm!
110112

111113
@consent_form.match_with_patient!(patient, current_user:)
114+
115+
reset_count!
112116
end
113117

114118
if patient.nhs_number.nil?
@@ -144,4 +148,8 @@ def set_patient
144148
def archive_params
145149
params.expect(consent_form: :notes).merge(archived_at: Time.current)
146150
end
151+
152+
def reset_count!
153+
TeamCachedCounts.new(current_team).reset_unmatched_consent_responses!
154+
end
147155
end

app/controllers/imports/issues_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def set_patient
7070
def set_form
7171
apply_changes = params.dig(:import_duplicate_form, :apply_changes)
7272

73-
@form = ImportDuplicateForm.new(object: @record, apply_changes:)
73+
@form =
74+
ImportDuplicateForm.new(current_team:, object: @record, apply_changes:)
7475
end
7576

7677
def set_type

app/forms/import_duplicate_form.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class ImportDuplicateForm
44
include ActiveModel::Model
55

6-
attr_accessor :object, :apply_changes
6+
attr_accessor :current_team, :object, :apply_changes
77

88
validates :apply_changes, inclusion: { in: :apply_changes_options }
99

@@ -21,6 +21,8 @@ def save
2121
end
2222
end
2323

24+
reset_count!
25+
2426
true
2527
rescue ActiveRecord::RecordInvalid
2628
errors.add(:base, "Failed to save changes")
@@ -51,4 +53,8 @@ def discard_pending_changes!
5153
def keep_both_changes!
5254
object.apply_pending_changes_to_new_record! if can_keep_both?
5355
end
56+
57+
def reset_count!
58+
TeamCachedCounts.new(current_team).reset_import_issues!
59+
end
5460
end

app/forms/school_move_form.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def save
2020
@school_move.ignore!
2121
end
2222

23+
TeamCachedCounts.new(team).reset_school_moves!
24+
2325
true
2426
end
27+
28+
private
29+
30+
def team = current_user.selected_team
2531
end

spec/features/import_child_records_with_duplicates_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def and_i_upload_a_file_with_duplicate_records
242242
end
243243

244244
def then_i_should_see_the_import_page_with_duplicate_records
245+
expect(page).to have_content("Imports (3)")
245246
expect(page).to have_content(
246247
"3 records have import issues to resolve before they can be imported into Mavis"
247248
)
@@ -364,11 +365,13 @@ def when_i_go_to_the_import_page
364365
end
365366

366367
def then_i_should_see_import_issues_with_the_count
368+
expect(page).to have_content("Imports (1)")
367369
expect(page).to have_link("Import issues")
368370
expect(page).to have_selector(".app-count", text: "(1)")
369371
end
370372

371373
def then_i_should_see_no_import_issues_with_the_count
374+
expect(page).to have_content("Imports (0)")
372375
expect(page).to have_link("Import issues")
373376
expect(page).to have_selector(".app-count", text: "(0)")
374377
end

spec/features/parental_consent_clinic_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def and_the_nurse_confirms_the_move
256256
choose "Update record with new school"
257257
click_on "Update child record"
258258
expect(page).to have_content("Success")
259+
expect(page).to have_content("School moves (0)")
259260
end
260261

261262
def then_the_nurse_should_see_no_moves

spec/features/parental_consent_manual_matching_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def given_the_patient_has_aged_out_of_the_programme
9191
def when_i_go_to_the_dashboard
9292
sign_in @user
9393
visit dashboard_path
94+
expect(page).to have_content("Unmatched responses (1)")
9495
end
9596

9697
def and_i_click_on_unmatched_consent_responses
@@ -135,6 +136,7 @@ def then_i_can_review_the_match
135136

136137
def when_i_link_the_response_with_the_record
137138
click_on "Link response with record"
139+
expect(page).to have_content("Unmatched responses (0)")
138140
end
139141

140142
def and_i_click_on_the_patient

0 commit comments

Comments
 (0)