diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 41a79fd3a..eb437b456 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -51,16 +51,20 @@ class Form::Question def get_inferred_answers(case_log) return [] unless inferred_answers - enabled_inferred_answers(inferred_answers, case_log).keys.map do |x| - question = form.get_question(x, case_log) + enabled_inferred_answers(inferred_answers, case_log).keys.map do |question_id| + question = form.get_question(question_id, case_log) if question.present? - question.label_from_value(case_log[x]) + question.label_from_value(case_log[question_id]) else - Array(x.to_s.split(".")).inject(case_log) { |o, a| o.present? ? o.public_send(*a) : "" } + Array(question_id.to_s.split(".")).inject(case_log) { |log, method| log.present? ? log.public_send(*method) : "" } end end end + def get_extra_check_answer_value(_case_log) + nil + end + def read_only? !!readonly end diff --git a/app/models/form/setup/questions/location_id.rb b/app/models/form/setup/questions/location_id.rb index d5a0976f7..cc8e1daf6 100644 --- a/app/models/form/setup/questions/location_id.rb +++ b/app/models/form/setup/questions/location_id.rb @@ -34,6 +34,10 @@ class Form::Setup::Questions::LocationId < ::Form::Question !supported_housing_selected?(case_log) end + def get_extra_check_answer_value(case_log) + case_log.form.get_question("la", nil).label_from_value(case_log.la) + end + private def supported_housing_selected?(case_log) diff --git a/app/views/form/_check_answers_summary_list.html.erb b/app/views/form/_check_answers_summary_list.html.erb index 6b7761437..d04dfa031 100644 --- a/app/views/form/_check_answers_summary_list.html.erb +++ b/app/views/form/_check_answers_summary_list.html.erb @@ -3,7 +3,12 @@ <% summary_list.row do |row| %> <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %> <% row.value do %> - <%= get_answer_label(question, @case_log) %>
+ <%= get_answer_label(question, @case_log) %> + <% extra_value = question.get_extra_check_answer_value(@case_log) %> + <% if extra_value %> + <%= extra_value %> + <% end %> +
<% question.get_inferred_answers(@case_log).each do |inferred_answer| %> <%= inferred_answer %> <% end %> diff --git a/db/seeds.rb b/db/seeds.rb index 264b25d69..86f6d3395 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -28,6 +28,7 @@ unless Rails.env.test? if Rails.env.development? && User.count.zero? User.create!( + name: "Provider", email: "provider@example.com", password: "password", organisation: org, @@ -36,6 +37,7 @@ unless Rails.env.test? ) User.create!( + name: "Coordinator", email: "coordinator@example.com", password: "password", organisation: org, @@ -44,6 +46,7 @@ unless Rails.env.test? ) User.create!( + name: "Support", email: "support@example.com", password: "password", organisation: org, diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_spec.rb index f495e9897..4e4253470 100644 --- a/spec/features/form/check_answers_page_spec.rb +++ b/spec/features/form/check_answers_page_spec.rb @@ -144,6 +144,13 @@ RSpec.describe "Form Check Answers Page" do expect(page).to have_content("Location") expect(page).to have_content(location.name) end + + it "displays inferred postcode with the location_admin_district" do + case_log.update!(location:) + visit("/logs/#{id}/setup/check-answers") + expect(page).to have_content("Location") + expect(page).to have_content(location.location_admin_district) + end end context "when the user changes their answer from check answer page" do