Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/controllers/consent_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def edit_match
def update_match
@consent_form.match_with_patient!(@patient, current_user:)

reset_count!

session =
@patient
.sessions
Expand Down Expand Up @@ -109,6 +111,8 @@ def create_patient
school_move.confirm!

@consent_form.match_with_patient!(patient, current_user:)

reset_count!
end

if patient.nhs_number.nil?
Expand Down Expand Up @@ -144,4 +148,8 @@ def set_patient
def archive_params
params.expect(consent_form: :notes).merge(archived_at: Time.current)
end

def reset_count!
TeamCachedCounts.new(current_team).reset_unmatched_consent_responses!
end
end
3 changes: 2 additions & 1 deletion app/controllers/imports/issues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def set_patient
def set_form
apply_changes = params.dig(:import_duplicate_form, :apply_changes)

@form = ImportDuplicateForm.new(object: @record, apply_changes:)
@form =
ImportDuplicateForm.new(current_team:, object: @record, apply_changes:)
end

def set_type
Expand Down
8 changes: 7 additions & 1 deletion app/forms/import_duplicate_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class ImportDuplicateForm
include ActiveModel::Model

attr_accessor :object, :apply_changes
attr_accessor :current_team, :object, :apply_changes

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

Expand All @@ -21,6 +21,8 @@ def save
end
end

reset_count!

true
rescue ActiveRecord::RecordInvalid
errors.add(:base, "Failed to save changes")
Expand Down Expand Up @@ -51,4 +53,8 @@ def discard_pending_changes!
def keep_both_changes!
object.apply_pending_changes_to_new_record! if can_keep_both?
end

def reset_count!
TeamCachedCounts.new(current_team).reset_import_issues!
end
end
6 changes: 6 additions & 0 deletions app/forms/school_move_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def save
@school_move.ignore!
end

TeamCachedCounts.new(team).reset_school_moves!

true
end

private

def team = current_user.selected_team
end
3 changes: 3 additions & 0 deletions spec/features/import_child_records_with_duplicates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def and_i_upload_a_file_with_duplicate_records
end

def then_i_should_see_the_import_page_with_duplicate_records
expect(page).to have_content("Imports (3)")
expect(page).to have_content(
"3 records have import issues to resolve before they can be imported into Mavis"
)
Expand Down Expand Up @@ -364,11 +365,13 @@ def when_i_go_to_the_import_page
end

def then_i_should_see_import_issues_with_the_count
expect(page).to have_content("Imports (1)")
expect(page).to have_link("Import issues")
expect(page).to have_selector(".app-count", text: "(1)")
end

def then_i_should_see_no_import_issues_with_the_count
expect(page).to have_content("Imports (0)")
expect(page).to have_link("Import issues")
expect(page).to have_selector(".app-count", text: "(0)")
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/parental_consent_clinic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def and_the_nurse_confirms_the_move
choose "Update record with new school"
click_on "Update child record"
expect(page).to have_content("Success")
expect(page).to have_content("School moves (0)")
end

def then_the_nurse_should_see_no_moves
Expand Down
2 changes: 2 additions & 0 deletions spec/features/parental_consent_manual_matching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def given_the_patient_has_aged_out_of_the_programme
def when_i_go_to_the_dashboard
sign_in @user
visit dashboard_path
expect(page).to have_content("Unmatched responses (1)")
end

def and_i_click_on_unmatched_consent_responses
Expand Down Expand Up @@ -135,6 +136,7 @@ def then_i_can_review_the_match

def when_i_link_the_response_with_the_record
click_on "Link response with record"
expect(page).to have_content("Unmatched responses (0)")
end

def and_i_click_on_the_patient
Expand Down