Skip to content

Commit 1060d03

Browse files
authored
Merge pull request #4757 from nhsuk/v4.4.1-wip
Version 4.4.1
2 parents 4b03f82 + ab7c5c4 commit 1060d03

4 files changed

Lines changed: 48 additions & 25 deletions

File tree

app/controllers/parent_interface/consent_forms/base_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ def authenticate_consent_form_user!
102102
end
103103

104104
def check_if_past_deadline!
105+
return if @session.unscheduled?
105106
return if @session.open_for_consent?
106107

107108
redirect_to deadline_passed_parent_interface_consent_forms_path(

app/models/consent_form.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def reason_notes_must_be_provided?
354354
end
355355

356356
def session
357-
# This tries to find the most approriate session for this consent form.
357+
# This tries to find the most appropriate session for this consent form.
358358
# It's used when generating links to patients in a session, or when
359359
# deciding which dates to show in an email. Under the hood, patients
360360
# belong to locations, not sessions.
@@ -365,7 +365,10 @@ def session
365365
# session.
366366

367367
@session ||=
368-
begin
368+
if location_is_clinic? || education_setting_home? ||
369+
education_setting_none?
370+
team.generic_clinic_session(academic_year:)
371+
else
369372
session_location = school || location
370373

371374
sessions_to_search =
@@ -375,16 +378,9 @@ def session
375378
team:
376379
)
377380

378-
if (scheduled_session = sessions_to_search.find(&:scheduled?))
379-
return scheduled_session
380-
end
381-
382-
if education_setting_home? || education_setting_none?
381+
sessions_to_search.find(&:scheduled?) ||
382+
sessions_to_search.find(&:unscheduled?) || sessions_to_search.first ||
383383
team.generic_clinic_session(academic_year:)
384-
else
385-
sessions_to_search.first ||
386-
team.generic_clinic_session(academic_year:)
387-
end
388384
end
389385
end
390386

spec/features/parental_consent_school_session_completed_spec.rb

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@
33
describe "Parental consent" do
44
around { |example| travel_to(Date.new(2025, 8, 1)) { example.run } }
55

6-
scenario "Move to a completed session" do
7-
stub_pds_search_to_return_no_patients
6+
before { stub_pds_search_to_return_no_patients }
87

8+
scenario "Move to an unscheduled session" do
99
given_an_hpv_programme_is_underway
1010

1111
when_i_go_to_the_consent_form
1212
and_i_fill_in_my_childs_name_and_birthday
13-
and_i_try_to_give_consent
13+
and_i_try_to_give_consent_for_the_unscheduled_school
14+
then_i_see_that_consent_is_open
15+
end
16+
17+
scenario "Move to a completed session" do
18+
given_an_hpv_programme_is_underway
19+
20+
when_i_go_to_the_consent_form
21+
and_i_fill_in_my_childs_name_and_birthday
22+
and_i_try_to_give_consent_for_the_completed_school
1423
then_i_see_that_consent_is_closed
1524
end
1625

@@ -20,10 +29,12 @@ def given_an_hpv_programme_is_underway
2029

2130
@subteam = create(:subteam, team: @team)
2231

23-
@scheduled_school =
32+
@unscheduled_school =
2433
create(:school, :secondary, name: "School 1", subteam: @subteam)
25-
@completed_school =
34+
@scheduled_school =
2635
create(:school, :secondary, name: "School 2", subteam: @subteam)
36+
@completed_school =
37+
create(:school, :secondary, name: "School 3", subteam: @subteam)
2738

2839
@scheduled_session =
2940
create(
@@ -34,6 +45,15 @@ def given_an_hpv_programme_is_underway
3445
location: @scheduled_school
3546
)
3647

48+
@unscheduled_session =
49+
create(
50+
:session,
51+
:unscheduled,
52+
team: @team,
53+
programmes: [@programme],
54+
location: @unscheduled_school
55+
)
56+
3757
@completed_session =
3858
create(
3959
:session,
@@ -69,14 +89,27 @@ def and_i_fill_in_my_childs_name_and_birthday
6989
click_on "Continue"
7090
end
7191

72-
def and_i_try_to_give_consent
92+
def and_i_try_to_give_consent_for_the_unscheduled_school
93+
choose "No, they go to a different school"
94+
click_on "Continue"
95+
96+
select @unscheduled_school.name
97+
click_on "Continue"
98+
end
99+
100+
def and_i_try_to_give_consent_for_the_completed_school
73101
choose "No, they go to a different school"
74102
click_on "Continue"
75103

76104
select @completed_school.name
77105
click_on "Continue"
78106
end
79107

108+
def then_i_see_that_consent_is_open
109+
expect(page).to have_content("About you")
110+
expect(page).to have_button("Continue")
111+
end
112+
80113
def then_i_see_that_consent_is_closed
81114
expect(page).to have_content("The deadline for responding has passed")
82115
expect(page).to have_content(

spec/models/consent_form_spec.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,17 +624,10 @@
624624
context "with an unscheduled and scheduled school session" do
625625
before do
626626
create(:session, :unscheduled, location: school, team:, programmes:)
627-
end
628-
629-
let!(:scheduled_school_session) do
630627
create(:session, :scheduled, location: school, team:, programmes:)
631628
end
632629

633-
# This intentionally returns the school session because the clinic session
634-
# might not be scheduled with dates yet (which is usually the case early
635-
# on at the beginning of the year), and without a session the user sees
636-
# a page saying the deadline has passed.
637-
it { should eq(scheduled_school_session) }
630+
it { should eq(generic_clinic_session) }
638631
end
639632
end
640633

0 commit comments

Comments
 (0)