diff --git a/app/models/form/page.rb b/app/models/form/page.rb index 2cdebff39..12b1065d6 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -1,6 +1,6 @@ class Form::Page attr_accessor :id, :header, :description, :questions, :soft_validations, - :depends_on, :subsection + :depends_on, :subsection, :hide_subsection_label def initialize(id, hsh, subsection) @id = id @@ -8,6 +8,7 @@ class Form::Page @description = hsh["description"] @questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) } @depends_on = hsh["depends_on"] + @hide_subsection_label = hsh["hide_subsection_label"] @soft_validations = hsh["soft_validations"]&.map { |sv_id, s| Form::Question.new(sv_id, s, self) } @subsection = subsection end diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index 8385eaac7..360d56520 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -16,11 +16,17 @@
<%= @page.description.html_safe %>
+ <% end %> + <%= form_with model: @case_log, url: form_case_log_path(@case_log), method: "post" do |f| %> <%= f.govuk_error_summary %> <% @page.questions.map do |question| %> diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index da5a0bb0e..f50480d15 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -26,9 +26,10 @@ } }, "gdpr_declined": { + "hide_subsection_label": true, "header": "You cannot use this service", "hint_text": "", - "description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.", + "description": "We cannot accept data about a tenant or buyer unless they’ve seen the DLUHC privacy notice.Test description with link.
' } + + it "renders the description" do + expect(rendered).to match(expected_html) + end + end + + context "given a page with a header" do + it "renders the header and the subsection label" do + expect(rendered).to match(page.header) + expect(rendered).to match(subsection.label) + end + end + + context "given a page with a header and hide_subsection_label true" do + let(:page_attributes) { { hide_subsection_label: true } } + + it "renders the header but not the subsection label" do + expect(rendered).to match(page.header) + expect(rendered).not_to match(subsection.label) + end end context "given a numeric question with prefix and suffix" do - let(:attribs) { { type: "numeric", prefix: "£", suffix: "every week" } } + let(:question_attributes) { { type: "numeric", prefix: "£", suffix: "every week" } } it "renders prefix and suffix text" do expect(rendered).to match(/govuk-input__prefix/) @@ -48,42 +79,42 @@ RSpec.describe "form/page" do let(:expected_guidance) { /What counts as income?/ } context "with radio type" do - let(:attribs) { { type: "radio", answer_options: { "1": "A", "2": "B" } } } + let(:question_attributes) { { type: "radio", answer_options: { "1": "A", "2": "B" } } } it "renders the guidance partial for radio questions" do expect(rendered).to match(expected_guidance) end end context "with text type" do - let(:attribs) { { type: "text", answer_options: nil } } + let(:question_attributes) { { type: "text", answer_options: nil } } it "renders the guidance partial for text questions" do expect(rendered).to match(expected_guidance) end end context "with numeric type" do - let(:attribs) { { type: "numeric", answer_options: nil } } + let(:question_attributes) { { type: "numeric", answer_options: nil } } it "renders the guidance partial for numeric questions" do expect(rendered).to match(expected_guidance) end end context "with select type" do - let(:attribs) { { type: "select", answer_options: { "1": "A", "2": "B" } } } + let(:question_attributes) { { type: "select", answer_options: { "1": "A", "2": "B" } } } it "renders the guidance partial for select questions" do expect(rendered).to match(expected_guidance) end end context "with checkbox type" do - let(:attribs) { { type: "checkbox", answer_options: { "1": "A", "2": "B" } } } + let(:question_attributes) { { type: "checkbox", answer_options: { "1": "A", "2": "B" } } } it "renders the guidance partial for checkbox questions" do expect(rendered).to match(expected_guidance) end end context "with date type" do - let(:attribs) { { type: "date", answer_options: nil } } + let(:question_attributes) { { type: "date", answer_options: nil } } it "renders the guidance partial for date questions" do expect(rendered).to match(expected_guidance) end