From ba265c14772bcd6eeb9a850e47731b8f8ca90247 Mon Sep 17 00:00:00 2001 From: Kat Date: Fri, 25 Aug 2023 09:38:41 +0100 Subject: [PATCH] Display question unanswered for empty strings --- app/helpers/details_table_helper.rb | 4 +++- spec/features/schemes_spec.rb | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 73972c4c3..ab6fc489c 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 uunanswered 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