Skip to content

Commit 07bad44

Browse files
authored
Merge pull request #6540 from NHSDigital/missing-already-had-emails
Move already had notification sending to after commit
2 parents 38b34df + 434a315 commit 07bad44

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

app/models/immunisation_import.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ def postprocess_rows!
217217

218218
PatientTeamUpdater.call(patient_scope: patients)
219219
PatientStatusUpdater.call(patient_scope: Patient.where(id: patients.ids))
220+
end
221+
222+
def post_commit!
223+
vaccination_records.sync_all_to_nhs_immunisations_api
220224

221225
vaccination_records
222226
.includes(:patient, :team, :subteam)
223227
.find_each do |vaccination_record|
224228
AlreadyHadNotificationSender.call(vaccination_record:)
225229
end
226230
end
227-
228-
def post_commit!
229-
vaccination_records.sync_all_to_nhs_immunisations_api
230-
end
231231
end

spec/models/immunisation_import_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,14 @@
539539
SyncVaccinationRecordToNHSJob
540540
).with(vaccination_record.id).once.on("immunisations_api_sync")
541541
end
542+
543+
it "calls the AlreadyHadNotificationSender for the vaccination record" do
544+
expect(AlreadyHadNotificationSender).to receive(:call).with(
545+
vaccination_record:
546+
)
547+
548+
immunisation_import.send :post_commit!
549+
end
542550
end
543551

544552
describe "#postprocess_rows!" do
@@ -576,13 +584,5 @@
576584
).by(1)
577585
end
578586
end
579-
580-
it "calls the AlreadyHadNotificationSender for the vaccination record" do
581-
expect(AlreadyHadNotificationSender).to receive(:call).with(
582-
vaccination_record:
583-
)
584-
585-
immunisation_import.send :postprocess_rows!
586-
end
587587
end
588588
end

0 commit comments

Comments
 (0)