diff --git a/app/helpers/details_table_helper.rb b/app/helpers/details_table_helper.rb index 9d7c16f22..b7f880fdf 100644 --- a/app/helpers/details_table_helper.rb +++ b/app/helpers/details_table_helper.rb @@ -4,7 +4,9 @@ module DetailsTableHelper list = attribute[:value].map { |value| "
  • #{value}
  • " }.join simple_format(list, { class: "govuk-list govuk-list--bullet" }, wrapper_tag: "ul") else - value = attribute[:value].is_a?(Array) ? attribute[:value].first : attribute[:value] || "You didn’t answer this question".html_safe + return simple_format(attribute[:value].first.to_s, { class: "govuk-body" }, wrapper_tag: "p") if attribute[:value].is_a?(Array) + + value = attribute[:value].presence || "You didn’t answer this question".html_safe simple_format(value.to_s, { class: "govuk-body" }, wrapper_tag: "p") end diff --git a/app/views/locations/local_authority.html.erb b/app/views/locations/local_authority.html.erb index 347f85866..8f1f2e90c 100644 --- a/app/views/locations/local_authority.html.erb +++ b/app/views/locations/local_authority.html.erb @@ -3,7 +3,7 @@ <% content_for :before_content do %> <%= govuk_back_link( href: case params[:referrer] - when "check_local_authority" + when "check_local_authority", "check_answers" scheme_location_check_answers_path(@scheme, @location, route: params[:route]) else scheme_location_postcode_path(@scheme, @location, route: params[:route], referrer: params[:referrer]) diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 73972c4c3..dd683312e 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -552,6 +552,13 @@ RSpec.describe "Schemes scheme Features" do fill_in_and_save_second_location expect(page).to have_content "Check your answers" end + + it "dispays correct text for unanswered questions" do + fill_in_and_save_location + location.update!(location_code: nil) + visit "/schemes/#{scheme.id}/locations/#{location.id}/check-answers" + expect(page).to have_content "You didn’t answer this question" + end end context "when viewing locations" do