Skip to content

Commit 52d2474

Browse files
authored
Merge pull request #6102 from NHSDigital/fix-flaky-test-with-programmes
Fix flaky test which was using sampled programmes
2 parents 8833820 + 9dedf59 commit 52d2474

1 file changed

Lines changed: 29 additions & 13 deletions

File tree

spec/jobs/email_delivery_job_spec.rb

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,39 @@
118118
expect(notify_log_entry.sent_by).to eq(sent_by)
119119
end
120120

121-
it "creates a log entry programme record" do
122-
expect { perform_now }.to change(NotifyLogEntry::Programme, :count).by(1)
121+
context "with a non-MMR programme" do
122+
let(:programmes) { [Programme.find("flu")] }
123123

124-
notify_log_entry_programme = NotifyLogEntry::Programme.last
124+
it "creates a log entry programme record" do
125+
expect { perform_now }.to change(NotifyLogEntry::Programme, :count).by(
126+
1
127+
)
125128

126-
expect(notify_log_entry_programme.programme_type).to eq(
127-
programmes.first.type
128-
)
129+
notify_log_entry_programme =
130+
NotifyLogEntry.last.notify_log_entry_programmes.first
129131

130-
disease_types =
131-
if programmes.first.mmr?
132-
Programme::Variant::DISEASE_TYPES.fetch("mmr")
133-
else
134-
programmes.first.disease_types
135-
end
132+
expect(notify_log_entry_programme.programme_type).to eq("flu")
133+
expect(notify_log_entry_programme.disease_types).to eq(%w[influenza])
134+
end
135+
end
136+
137+
context "with an MMR programme and disease types" do
138+
let(:programmes) { [Programme.find("mmr")] }
139+
let(:disease_types) { %w[measles mumps rubella] }
136140

137-
expect(notify_log_entry_programme.disease_types).to eq(disease_types)
141+
it "creates a log entry programme record with variant disease types" do
142+
expect { perform_now }.to change(NotifyLogEntry::Programme, :count).by(
143+
1
144+
)
145+
146+
notify_log_entry_programme =
147+
NotifyLogEntry.last.notify_log_entry_programmes.first
148+
149+
expect(notify_log_entry_programme.programme_type).to eq("mmr")
150+
expect(notify_log_entry_programme.disease_types).to eq(
151+
%w[measles mumps rubella]
152+
)
153+
end
138154
end
139155

140156
context "when the parent doesn't have an email address" do

0 commit comments

Comments
 (0)