Skip to content

Commit ca32ee1

Browse files
committed
Don't ask to give details for start of follow up questions
If asking follow up health questions, the first question in the flow should not require the user to provide additional details if they choose "Yes". Instead, the additional details are shown as asked as part of the follow up questions.
1 parent 5d697de commit ca32ee1

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

app/helpers/consent_forms_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module ConsentFormsHelper
44
def health_answer_response(health_answer)
55
if health_answer.response == "yes"
6-
"Yes#{health_answer.notes}"
6+
["Yes", health_answer.notes].join(" – ")
77
else
88
"No"
99
end

app/models/health_answer.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ class HealthAnswer
1111
:next_question,
1212
:follow_up_question
1313

14-
validates :notes, length: { maximum: 1000 }
15-
1614
validates :response, inclusion: { in: %w[yes no] }
17-
validates :notes, presence: true, if: -> { response == "yes" }
15+
16+
validates :notes,
17+
presence: true,
18+
if: -> { requires_notes? && response == "yes" }
19+
validates :notes, length: { maximum: 1000 }
1820

1921
def attributes
2022
%i[
@@ -41,6 +43,8 @@ def assign_attributes(attrs)
4143
super(attrs)
4244
end
4345

46+
def requires_notes? = follow_up_question.nil?
47+
4448
def self.from_health_questions(health_questions)
4549
hq_id_map = Hash[health_questions.map.with_index { |hq, i| [hq.id, i] }]
4650

app/views/parent_interface/consent_forms/edit/health_question.html.erb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212

1313
<%= hidden_field_tag "question_number", @question_number %>
1414

15-
<%= f.govuk_radio_buttons_fieldset(:response,
15+
<%= f.govuk_radio_buttons_fieldset :response,
1616
legend: { size: "l", text: title, tag: "h1" },
17-
hint: { text: @health_answer.hint }) do %>
18-
<%= f.govuk_radio_button :response, "yes",
19-
label: { text: "Yes" },
20-
link_errors: true do %>
21-
<%= f.govuk_text_area :notes,
22-
label: { text: "Give details" } %>
17+
hint: { text: @health_answer.hint } do %>
18+
<% if @health_answer.requires_notes? %>
19+
<%= f.govuk_radio_button :response, "yes", label: { text: "Yes" }, link_errors: true do %>
20+
<%= f.govuk_text_area :notes, label: { text: "Give details" } %>
21+
<% end %>
22+
<% else %>
23+
<%= f.govuk_radio_button :response, "yes", label: { text: "Yes" }, link_errors: true %>
2324
<% end %>
24-
<%= f.govuk_radio_button :response, "no",
25-
label: { text: "No" } %>
25+
26+
<%= f.govuk_radio_button :response, "no", label: { text: "No" } %>
2627
<% end %>
2728

2829
<%= f.govuk_submit "Continue" %>

spec/features/parental_consent_change_answers_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def then_i_see_the_health_question
163163

164164
def when_i_change_my_answer_to_yes_for_the_asthma_question
165165
choose "Yes"
166-
fill_in "Give details", with: "He has had asthma since he was 2"
167166
click_button "Continue"
168167
end
169168

@@ -192,8 +191,6 @@ def then_i_see_the_second_follow_up_question
192191
end
193192

194193
def and_i_see_the_answer_i_changed_is_yes
195-
expect(page).to have_content("Yes – He has had asthma since he was 2")
196-
197194
expect(page).to have_content("Yes – Follow up details")
198195
expect(page).to have_content("Yes – Even more follow up details")
199196
end

spec/features/parental_consent_flu_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def when_i_change_my_answer_to_the_first_health_question
9191
click_link "Change your answer to health question 1"
9292

9393
choose "Yes"
94-
fill_in "Give details", with: "They have asthma"
9594
click_button "Continue"
9695
end
9796

0 commit comments

Comments
 (0)