|
12 | 12 |
|
13 | 13 | let(:programme) { Programme.hpv } |
14 | 14 | 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 |
16 | 23 |
|
17 | 24 | let(:vaccine) { programme.vaccines.first } |
18 | 25 | let(:batch) { create(:batch, team:, vaccine:, expiry: Date.new(2026, 11, 1)) } |
|
80 | 87 |
|
81 | 88 | it "has an error" do |
82 | 89 | 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( |
84 | 93 | "The vaccination cannot take place before 1 September 2024" |
85 | 94 | ) |
86 | 95 | end |
87 | 96 | end |
88 | 97 | end |
89 | 98 |
|
90 | 99 | 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 |
92 | 108 | let(:attributes) do |
93 | 109 | valid_administered_attributes.merge( |
94 | 110 | performed_at: Time.zone.local(2023, 8, 31, 12), |
|
104 | 120 |
|
105 | 121 | it "has an error" do |
106 | 122 | 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( |
108 | 126 | "The vaccination cannot take place before 1 September 2024" |
109 | 127 | ) |
110 | 128 | end |
|
126 | 144 |
|
127 | 145 | it "is valid" do |
128 | 146 | 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 |
130 | 150 | end |
131 | 151 | end |
132 | 152 |
|
133 | 153 | 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 |
135 | 162 | let(:attributes) do |
136 | 163 | valid_administered_attributes.merge( |
137 | 164 | performed_at: Time.zone.local(2020, 8, 30, 12), |
|
145 | 172 |
|
146 | 173 | it "has an error" do |
147 | 174 | 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( |
149 | 178 | "The vaccination cannot take place before 31 August 2020" |
150 | 179 | ) |
151 | 180 | end |
|
0 commit comments