Browse Source

Display question unanswered for empty strings

pull/1870/head
Kat 3 years ago
parent
commit
ba265c1477
  1. 4
      app/helpers/details_table_helper.rb
  2. 7
      spec/features/schemes_spec.rb

4
app/helpers/details_table_helper.rb

@ -4,7 +4,9 @@ module DetailsTableHelper
list = attribute[:value].map { |value| "<li>#{value}</li>" }.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] || "<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".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 || "<span class=\"app-!-colour-muted\">You didn’t answer this question</span>".html_safe
simple_format(value.to_s, { class: "govuk-body" }, wrapper_tag: "p")
end

7
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

Loading…
Cancel
Save