File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -421,23 +421,20 @@ def requires_care_setting?
421
421
def performed_by_details_present_where_required
422
422
if outcome_in_this_academic_year?
423
423
errors . add ( :performed_by_user , :blank ) if performed_by_user . nil?
424
- elsif @programme . hpv? # previous academic years from here on
425
- nil
426
- # no validation required
427
- elsif @programme . flu?
424
+ else # previous academic years from here on
428
425
email_field_populated =
429
426
@data [ "PERFORMING_PROFESSIONAL_EMAIL" ] &.strip . present?
430
- if !email_field_populated &&
431
- ( performed_by_given_name . blank? || performed_by_family_name . blank? )
427
+
428
+ if email_field_populated
429
+ errors . add ( :performed_by_user , :blank ) if performed_by_user . nil?
430
+ elsif @programme . flu? # no validation required for HPV
432
431
if performed_by_given_name . blank?
433
432
errors . add ( :performed_by_given_name , :blank )
434
433
end
435
434
if performed_by_family_name . blank?
436
435
errors . add ( :performed_by_family_name , :blank )
437
436
end
438
437
end
439
- else
440
- raise "Unexpected programme"
441
438
end
442
439
end
443
440
Original file line number Diff line number Diff line change 343
343
it { should be_valid }
344
344
end
345
345
346
+ context "HPV vaccination in previous academic year, vaccinator email provided but doesn't exist" do
347
+ let ( :data ) do
348
+ valid_hpv_data . merge (
349
+ "PERFORMING_PROFESSIONAL_EMAIL" => "non-existent@example.com" ,
350
+ "DATE_OF_VACCINATION" => "20220101"
351
+ )
352
+ end
353
+
354
+ it "has errors" do
355
+ expect ( immunisation_import_row ) . to be_invalid
356
+ expect ( immunisation_import_row . errors [ :performed_by_user ] ) . to include (
357
+ "Enter a valid email address"
358
+ )
359
+ end
360
+ end
361
+
346
362
context "Flu vaccination in previous academic year, no vaccinator details provided" do
347
363
let ( :data ) do
348
364
valid_flu_data . except (
You can’t perform that action at this time.
0 commit comments