Browse Source

Add test for check answers questions labels

pull/25/head
MadeTech Dushan 3 years ago
parent
commit
c73074bc0e
  1. 6
      app/controllers/case_logs_controller.rb
  2. 9
      app/views/form/check_answers.html.erb
  3. 7
      config/forms/2021_2022.json
  4. 11
      spec/features/case_log_spec.rb

6
app/controllers/case_logs_controller.rb

@ -40,7 +40,11 @@ class CaseLogsController < ApplicationController
def check_answers def check_answers
@case_log = CaseLog.find(params[:case_log_id]) @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 end
form = Form.new(2021, 2022) form = Form.new(2021, 2022)

9
app/views/form/check_answers.html.erb

@ -1,5 +1,14 @@
<%= turbo_frame_tag "case_log_form", target: "_top" do %> <%= turbo_frame_tag "case_log_form", target: "_top" do %>
<h1 class="govuk-heading-l">Check the answers you gave for household characteristics</h1> <h1 class="govuk-heading-l">Check the answers you gave for household characteristics</h1>
<% subsection_pages.each do |page, page_info| %>
<dl class="govuk-summary-list govuk-!-margin-bottom-9">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">
<%= page_info["check_answer_label"].to_s %>
<dt>
</div>
</dl>
<% end %>
<%= form_with action: '/case_logs', method: "next_page", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> <%= form_with action: '/case_logs', method: "next_page", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
<%= f.govuk_submit "Save and continue" %> <%= f.govuk_submit "Save and continue" %>
<% end %> <% end %>

7
config/forms/2021_2022.json

@ -10,6 +10,7 @@
"label": "Household characteristics", "label": "Household characteristics",
"pages": { "pages": {
"tenant_code":{ "tenant_code":{
"check_answer_label": "Tenant code",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{
@ -21,6 +22,7 @@
} }
}, },
"tenant_age":{ "tenant_age":{
"check_answer_label": "Tenant's age",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{
@ -35,6 +37,7 @@
} }
}, },
"tenant_gender":{ "tenant_gender":{
"check_answer_label": "Tenant's gender",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{
@ -52,6 +55,7 @@
} }
}, },
"tenant_ethnic_group":{ "tenant_ethnic_group":{
"check_answer_label": "Ethnicity",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{
@ -84,6 +88,7 @@
} }
}, },
"tenant_nationality":{ "tenant_nationality":{
"check_answer_label": "Nationality",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{
@ -113,6 +118,7 @@
} }
}, },
"tenant_economic_status":{ "tenant_economic_status":{
"check_answer_label": "Work",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{
@ -137,6 +143,7 @@
} }
}, },
"household_number_of_other_members":{ "household_number_of_other_members":{
"check_answer_label": "Number of Other Household Members",
"header": "", "header": "",
"description": "", "description": "",
"questions":{ "questions":{

11
spec/features/case_log_spec.rb

@ -113,6 +113,17 @@ RSpec.describe "Test Features" do
click_button("Save and continue") click_button("Save and continue")
expect(page).to have_current_path("/case_logs/#{id}/#{subsection}/check_answers") expect(page).to have_current_path("/case_logs/#{id}/#{subsection}/check_answers")
end 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 end
end end

Loading…
Cancel
Save