Skip to content

Commit fb9502c

Browse files
authored
Merge pull request #6482 from NHSDigital/fix-follow-up-request-status
Clear follow_up_requested on changing refusal reason
2 parents 5424aaf + 51a6d08 commit fb9502c

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

app/controllers/parent_interface/consent_forms/edit_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def update
4545
@consent_form.parent_phone.present?
4646
jump_to("contact-method", skip_to_confirm: true)
4747
end
48+
elsif is_reason_for_refusal_step?
49+
@consent_form.reset_follow_up_requested
4850
elsif is_injection_alternative_step?
4951
@consent_form.update_injection_alternative
5052
@consent_form.seed_health_questions
@@ -269,6 +271,8 @@ def is_without_gelatine_step? = step == "without-gelatine"
269271

270272
def is_health_question_step? = step == "health-question"
271273

274+
def is_reason_for_refusal_step? = step == "reason-for-refusal"
275+
272276
def current_health_answer
273277
index = step.split("-").last.to_i - 1
274278
@consent_form.health_answers[index]

app/models/consent_form.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,12 @@ def reason_for_refusal=(value)
576576
.each { it.reason_for_refusal = value }
577577
end
578578

579+
def reset_follow_up_requested
580+
consent_form_programmes
581+
.select(&:response_refused?)
582+
.each { it.follow_up_requested = nil }
583+
end
584+
579585
def reason_for_refusal_notes
580586
consent_form_programmes.find(&:response_refused?)&.notes
581587
end

spec/features/parental_consent_refused_spec.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
then_i_see_the_consent_page
1515

1616
when_i_refuse_consent
17+
then_i_see_the_follow_up_question
18+
when_i_request_follow_up
1719
then_i_can_check_my_answers
1820

21+
when_i_change_my_refusal_reason
22+
then_the_consent_doesnt_have_follow_up_requested_stored
23+
1924
when_i_confirm_my_answers
2025
and_i_refuse_to_answer_questions_on_ethnicity
2126
then_i_see_the_confirmation_page
@@ -91,14 +96,33 @@ def when_i_refuse_consent
9196
)
9297
fill_in "Give details", with: "They have a weakened immune system"
9398
click_on "Continue"
99+
end
94100

101+
def then_i_see_the_follow_up_question
95102
expect(page).to have_content(
96103
"Would you like a member of the team to contact you to discuss alternative options?"
97104
)
98-
choose "No"
105+
end
106+
107+
def when_i_request_follow_up
108+
choose "Yes, I would like someone to contact me"
99109
click_on "Continue"
100110
end
101111

112+
def when_i_change_my_refusal_reason
113+
click_on "Change reason for refusal"
114+
choose "Vaccine already received"
115+
click_on "Continue"
116+
117+
fill_in "Give details",
118+
with: "They will receive the vaccine at another location"
119+
click_on "Continue"
120+
end
121+
122+
def then_the_consent_doesnt_have_follow_up_requested_stored
123+
expect(ConsentForm.last.follow_up_requested).to be_nil
124+
end
125+
102126
def when_i_refuse_consent_and_request_follow_up
103127
expect(page).to have_content("Do you agree")
104128
choose "No"

0 commit comments

Comments
 (0)