From c73074bc0e62ba25ab15ccbaaf98f12348cc7d5a Mon Sep 17 00:00:00 2001 From: MadeTech Dushan Date: Wed, 29 Sep 2021 12:20:00 +0100 Subject: [PATCH] Add test for check answers questions labels --- app/controllers/case_logs_controller.rb | 6 +++++- app/views/form/check_answers.html.erb | 9 +++++++++ config/forms/2021_2022.json | 7 +++++++ spec/features/case_log_spec.rb | 11 +++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/controllers/case_logs_controller.rb b/app/controllers/case_logs_controller.rb index e1e2d8890..54afdeffe 100644 --- a/app/controllers/case_logs_controller.rb +++ b/app/controllers/case_logs_controller.rb @@ -40,7 +40,11 @@ class CaseLogsController < ApplicationController def check_answers @case_log = CaseLog.find(params[:case_log_id]) - render "form/check_answers", locals: { case_log_id: @case_log.id } + form = Form.new(2021, 2022) + current_url = request.env['PATH_INFO'] + subsection = current_url.split('/')[-2] + subsection_pages = form.pages_for_subsection(subsection) + render "form/check_answers", locals: { case_log_id: @case_log.id, subsection_pages: subsection_pages } end form = Form.new(2021, 2022) diff --git a/app/views/form/check_answers.html.erb b/app/views/form/check_answers.html.erb index 5f1310211..f9122a0a2 100644 --- a/app/views/form/check_answers.html.erb +++ b/app/views/form/check_answers.html.erb @@ -1,5 +1,14 @@ <%= turbo_frame_tag "case_log_form", target: "_top" do %>

Check the answers you gave for household characteristics

+ <% subsection_pages.each do |page, page_info| %> +
+
+
+ <%= page_info["check_answer_label"].to_s %> +
+
+
+ <% end %> <%= form_with action: '/case_logs', method: "next_page", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= f.govuk_submit "Save and continue" %> <% end %> diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 83d80674a..9e84b9e55 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -10,6 +10,7 @@ "label": "Household characteristics", "pages": { "tenant_code":{ + "check_answer_label": "Tenant code", "header": "", "description": "", "questions":{ @@ -21,6 +22,7 @@ } }, "tenant_age":{ + "check_answer_label": "Tenant's age", "header": "", "description": "", "questions":{ @@ -35,6 +37,7 @@ } }, "tenant_gender":{ + "check_answer_label": "Tenant's gender", "header": "", "description": "", "questions":{ @@ -52,6 +55,7 @@ } }, "tenant_ethnic_group":{ + "check_answer_label": "Ethnicity", "header": "", "description": "", "questions":{ @@ -84,6 +88,7 @@ } }, "tenant_nationality":{ + "check_answer_label": "Nationality", "header": "", "description": "", "questions":{ @@ -113,6 +118,7 @@ } }, "tenant_economic_status":{ + "check_answer_label": "Work", "header": "", "description": "", "questions":{ @@ -137,6 +143,7 @@ } }, "household_number_of_other_members":{ + "check_answer_label": "Number of Other Household Members", "header": "", "description": "", "questions":{ diff --git a/spec/features/case_log_spec.rb b/spec/features/case_log_spec.rb index bc76a9231..2501ed1a4 100644 --- a/spec/features/case_log_spec.rb +++ b/spec/features/case_log_spec.rb @@ -113,6 +113,17 @@ RSpec.describe "Test Features" do click_button("Save and continue") expect(page).to have_current_path("/case_logs/#{id}/#{subsection}/check_answers") end + + it "has question headings based on the subsection" do + visit("case_logs/#{id}/#{subsection}/check_answers") + expect(page).to have_content("Tenant code") + expect(page).to have_content("Tenant's age") + expect(page).to have_content("Tenant's gender") + expect(page).to have_content("Ethnicity") + expect(page).to have_content("Nationality") + expect(page).to have_content("Work") + expect(page).to have_content("Number of Other Household Members") + end end end end