Skip to content

Commit 8725620

Browse files
Merge pull request #4252 from nhsuk/deduplicate-programme-in-notice
Fix duplication of programme name in notice
2 parents dc8316c + 40c2419 commit 8725620

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

app/lib/important_notices.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def notices_for_patient(patient)
7171
patient.vaccination_records.select { it.notify_parents == false }
7272
if no_notify_vaccination_records.any?
7373
vaccinations_sentence =
74-
"#{no_notify_vaccination_records.map(&:programme).map(&:name).to_sentence} " \
74+
"#{no_notify_vaccination_records.map(&:programme).uniq.map(&:name).to_sentence} " \
7575
"#{"vaccination".pluralize(no_notify_vaccination_records.length)}"
7676

7777
notices << {

spec/lib/important_notices_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,25 @@
8181
end
8282
end
8383

84+
context "when patient has multiple vaccination records with the same programme" do
85+
let(:first_record) do
86+
create(:vaccination_record, patient:, programme:, notify_parents: false)
87+
end
88+
let(:second_record) do
89+
create(:vaccination_record, patient:, programme:, notify_parents: false)
90+
end
91+
92+
before do
93+
first_record
94+
second_record
95+
end
96+
97+
it "only writes the programme name once in the message" do
98+
expect(notices.count).to eq(1)
99+
expect(notices.first[:message].scan("HPV").count).to eq(1)
100+
end
101+
end
102+
84103
context "when patient has multiple vaccination records with the same notify_parents values" do
85104
let(:other_programme) { create(:programme, :flu) }
86105

0 commit comments

Comments
 (0)