Skip to content

Commit bf0e01a

Browse files
committed
Fix spec regressions
1 parent e2c5073 commit bf0e01a

3 files changed

Lines changed: 106 additions & 32 deletions

File tree

spec/features/mmr_already_had_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,16 @@ def and_the_dose_number_is_second
321321
end
322322

323323
def and_the_performed_at_date_and_time_are_set
324-
expect(page).to have_content("Date#{@vaccination_date.strftime('%-d %B %Y')}")
324+
expect(page).to have_content(
325+
"Date#{@vaccination_date.strftime("%-d %B %Y")}"
326+
)
325327
expect(page).to have_content("Time12:30")
326328
end
327329

328330
def and_the_performed_at_date_only_is_set
329-
expect(page).to have_content("Date#{@vaccination_date.strftime('%-d %B %Y')}")
331+
expect(page).to have_content(
332+
"Date#{@vaccination_date.strftime("%-d %B %Y")}"
333+
)
330334
end
331335

332336
def and_the_consent_requests_are_sent

spec/helpers/vaccination_records_helper_spec.rb

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,80 @@
1010
let(:session) { create(:session, :today, team:, programmes: [programme]) }
1111
let(:patient) { build(:patient, id: 123) }
1212

13-
context "on the MMR programme" do
14-
let(:programme) { Programme.mmr }
13+
context "with the `already_vaccinated` feature flag enabled" do
14+
before { Flipper.enable(:already_vaccinated) }
1515

16-
context "when patient has NOT had their first dose" do
17-
it { should eq("Record 1st dose as already given") }
18-
end
16+
context "on the MMR programme" do
17+
let(:programme) { Programme.mmr }
1918

20-
context "when patient has had their first dose" do
21-
let(:patient) do
22-
build(
23-
:patient,
24-
:consent_no_response,
25-
id: 123,
26-
programmes: [Programme.mmr]
27-
)
19+
context "when patient has NOT had their first dose" do
20+
it { should eq("Record 1st dose as already given") }
2821
end
2922

30-
before do
31-
patient.programme_status(
32-
programme,
33-
academic_year: AcademicYear.current
34-
).dose_sequence =
35-
2
23+
context "when patient has had their first dose" do
24+
let(:patient) do
25+
build(
26+
:patient,
27+
:consent_no_response,
28+
id: 123,
29+
programmes: [Programme.mmr]
30+
)
31+
end
32+
33+
before do
34+
patient.programme_status(
35+
programme,
36+
academic_year: AcademicYear.current
37+
).dose_sequence =
38+
2
39+
end
40+
41+
it { should eq("Record 2nd dose as already given") }
3642
end
43+
end
3744

38-
it { should eq("Record 2nd dose as already given") }
45+
context "on the flu programme" do
46+
let(:programme) { Programme.flu }
47+
48+
it { should eq("Record as already vaccinated") }
3949
end
4050
end
4151

42-
context "on the flu programme" do
43-
let(:programme) { Programme.flu }
52+
context "with the `already_vaccinated` feature flag disabled" do
53+
context "on the MMR programme" do
54+
let(:programme) { Programme.mmr }
55+
56+
context "when patient has NOT had their first dose" do
57+
it { should eq("Record as already vaccinated") }
58+
end
59+
60+
context "when patient has had their first dose" do
61+
let(:patient) do
62+
build(
63+
:patient,
64+
:consent_no_response,
65+
id: 123,
66+
programmes: [Programme.mmr]
67+
)
68+
end
69+
70+
before do
71+
patient.programme_status(
72+
programme,
73+
academic_year: AcademicYear.current
74+
).dose_sequence =
75+
2
76+
end
4477

45-
it { should eq("Record as already vaccinated") }
78+
it { should eq("Record as already vaccinated") }
79+
end
80+
end
81+
82+
context "on the flu programme" do
83+
let(:programme) { Programme.flu }
84+
85+
it { should eq("Record as already vaccinated") }
86+
end
4687
end
4788
end
4889
end

spec/models/draft_vaccination_record_spec.rb

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212

1313
let(:programme) { Programme.hpv }
1414
let(:session) { create(:session, team:, programmes: [programme]) }
15-
let(:patient) { create(:patient, :in_attendance, session:, date_of_birth: Date.new(2020, 8, 31)) }
15+
let(:patient) do
16+
create(
17+
:patient,
18+
:in_attendance,
19+
session:,
20+
date_of_birth: Date.new(2020, 8, 31)
21+
)
22+
end
1623

1724
let(:vaccine) { programme.vaccines.first }
1825
let(:batch) { create(:batch, team:, vaccine:, expiry: Date.new(2026, 11, 1)) }
@@ -80,15 +87,24 @@
8087

8188
it "has an error" do
8289
expect(draft_vaccination_record.save(context: :update)).to be(false)
83-
expect(draft_vaccination_record.errors[:performed_at_date]).to include(
90+
expect(
91+
draft_vaccination_record.errors[:performed_at_date]
92+
).to include(
8493
"The vaccination cannot take place before 1 September 2024"
8594
)
8695
end
8796
end
8897
end
8998

9099
context "when the record is national reporting" do
91-
let(:team) { create(:team, :national_reporting, :with_one_nurse, programmes: [programme]) }
100+
let(:team) do
101+
create(
102+
:team,
103+
:national_reporting,
104+
:with_one_nurse,
105+
programmes: [programme]
106+
)
107+
end
92108
let(:attributes) do
93109
valid_administered_attributes.merge(
94110
performed_at: Time.zone.local(2023, 8, 31, 12),
@@ -104,7 +120,9 @@
104120

105121
it "has an error" do
106122
expect(draft_vaccination_record.save(context: :update)).to be(false)
107-
expect(draft_vaccination_record.errors[:performed_at_date]).to include(
123+
expect(
124+
draft_vaccination_record.errors[:performed_at_date]
125+
).to include(
108126
"The vaccination cannot take place before 1 September 2024"
109127
)
110128
end
@@ -126,12 +144,21 @@
126144

127145
it "is valid" do
128146
expect(draft_vaccination_record.save(context: :update)).to be(true)
129-
expect(draft_vaccination_record.errors[:performed_at_date]).to be_empty
147+
expect(
148+
draft_vaccination_record.errors[:performed_at_date]
149+
).to be_empty
130150
end
131151
end
132152

133153
context "when performed_at is before patient date of birth" do
134-
let(:patient) { create(:patient, :in_attendance, session:, date_of_birth: Date.new(2020, 8, 31)) }
154+
let(:patient) do
155+
create(
156+
:patient,
157+
:in_attendance,
158+
session:,
159+
date_of_birth: Date.new(2020, 8, 31)
160+
)
161+
end
135162
let(:attributes) do
136163
valid_administered_attributes.merge(
137164
performed_at: Time.zone.local(2020, 8, 30, 12),
@@ -145,7 +172,9 @@
145172

146173
it "has an error" do
147174
expect(draft_vaccination_record.save(context: :update)).to be(false)
148-
expect(draft_vaccination_record.errors[:performed_at_date]).to include(
175+
expect(
176+
draft_vaccination_record.errors[:performed_at_date]
177+
).to include(
149178
"The vaccination cannot take place before 31 August 2020"
150179
)
151180
end

0 commit comments

Comments
 (0)