Skip to content

Commit baae3e8

Browse files
committed
Fix for consent confirmation comms not appearing in the activity log
Jira-Issue: MAV-5062
1 parent baa8947 commit baae3e8

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

app/lib/govuk_notify_personalisation.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def initialize(
2525
@consent = consent
2626
@consent_form = consent_form
2727
@parent = parent || consent&.parent
28-
@patient = patient || consent&.patient || vaccination_record&.patient
28+
@patient =
29+
patient || consent&.patient || vaccination_record&.patient ||
30+
Patient.find_by(id: consent_form&.matched_patient&.id)
2931
@session = session || consent_form&.session || vaccination_record&.session
3032
@team =
3133
team || session&.team || consent_form&.team || consent&.team ||

spec/features/parental_consent_inexact_auto_match_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,6 @@ def and_they_see_consent_contact_warning_notifications
121121
expect(page).to have_content("Consent unknown contact details warning sent")
122122
expect(page).to have_content(@parent.email)
123123
expect(page).to have_content(@parent.phone)
124+
expect(page).to have_content("Consent confirmation given sent")
124125
end
125126
end

spec/jobs/email_delivery_job_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,24 @@
206206
expect(notify_log_entry.programmes.map(&:type)).to eq(programme_types)
207207
end
208208

209+
context "when the consent form is matched to a patient" do
210+
let(:matched_patient) { create(:patient) }
211+
212+
before do
213+
create(
214+
:consent,
215+
programme: session.programmes.first,
216+
consent_form:,
217+
patient: matched_patient
218+
)
219+
end
220+
221+
it "sets patient on the log entry from the matched consent form" do
222+
perform_now
223+
expect(NotifyLogEntry.last.patient).to eq(matched_patient)
224+
end
225+
end
226+
209227
context "when the parent doesn't have a phone number" do
210228
let(:consent_form) do
211229
create(:consent_form, session:, parent_email: nil)

0 commit comments

Comments
 (0)