Browse Source

CLDC-1372 Show inferred location when checking log answers (#780)

* spiked extra values for location la

* test

* extra test

* extra spacing

* renamed argument

* refactored per Dans suggestions

* redundant tests

* redundant method

* redundant method

* redundant method - part 3

* redundant method - part 4
pull/783/head
J G 2 years ago committed by GitHub
parent
commit
a2a9aa4e6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/models/form/question.rb
  2. 4
      app/models/form/setup/questions/location_id.rb
  3. 7
      app/views/form/_check_answers_summary_list.html.erb
  4. 3
      db/seeds.rb
  5. 7
      spec/features/form/check_answers_page_spec.rb

12
app/models/form/question.rb

@ -51,16 +51,20 @@ class Form::Question
def get_inferred_answers(case_log) def get_inferred_answers(case_log)
return [] unless inferred_answers return [] unless inferred_answers
enabled_inferred_answers(inferred_answers, case_log).keys.map do |x| enabled_inferred_answers(inferred_answers, case_log).keys.map do |question_id|
question = form.get_question(x, case_log) question = form.get_question(question_id, case_log)
if question.present? if question.present?
question.label_from_value(case_log[x]) question.label_from_value(case_log[question_id])
else 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 end
end end
def get_extra_check_answer_value(_case_log)
nil
end
def read_only? def read_only?
!!readonly !!readonly
end end

4
app/models/form/setup/questions/location_id.rb

@ -34,6 +34,10 @@ class Form::Setup::Questions::LocationId < ::Form::Question
!supported_housing_selected?(case_log) !supported_housing_selected?(case_log)
end end
def get_extra_check_answer_value(case_log)
case_log.form.get_question("la", nil).label_from_value(case_log.la)
end
private private
def supported_housing_selected?(case_log) def supported_housing_selected?(case_log)

7
app/views/form/_check_answers_summary_list.html.erb

@ -3,7 +3,12 @@
<% summary_list.row do |row| %> <% summary_list.row do |row| %>
<% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %> <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %>
<% row.value do %> <% row.value do %>
<%= get_answer_label(question, @case_log) %><br> <span class="govuk-!-margin-right-4"><%= get_answer_label(question, @case_log) %></span>
<% extra_value = question.get_extra_check_answer_value(@case_log) %>
<% if extra_value %>
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= extra_value %></span>
<% end %>
<br>
<% question.get_inferred_answers(@case_log).each do |inferred_answer| %> <% question.get_inferred_answers(@case_log).each do |inferred_answer| %>
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= inferred_answer %></span> <span class="govuk-!-font-weight-regular app-!-colour-muted"><%= inferred_answer %></span>
<% end %> <% end %>

3
db/seeds.rb

@ -28,6 +28,7 @@ unless Rails.env.test?
if Rails.env.development? && User.count.zero? if Rails.env.development? && User.count.zero?
User.create!( User.create!(
name: "Provider",
email: "provider@example.com", email: "provider@example.com",
password: "password", password: "password",
organisation: org, organisation: org,
@ -36,6 +37,7 @@ unless Rails.env.test?
) )
User.create!( User.create!(
name: "Coordinator",
email: "coordinator@example.com", email: "coordinator@example.com",
password: "password", password: "password",
organisation: org, organisation: org,
@ -44,6 +46,7 @@ unless Rails.env.test?
) )
User.create!( User.create!(
name: "Support",
email: "support@example.com", email: "support@example.com",
password: "password", password: "password",
organisation: org, organisation: org,

7
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")
expect(page).to have_content(location.name) expect(page).to have_content(location.name)
end 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 end
context "when the user changes their answer from check answer page" do context "when the user changes their answer from check answer page" do

Loading…
Cancel
Save