Browse Source

Update displayed questions

pull/1763/head
Kat 3 years ago
parent
commit
45d06e957c
  1. 12
      app/controllers/duplicate_logs_controller.rb
  2. 14
      app/views/duplicate_logs/_duplicate_log_check_answers.erb
  3. 6
      spec/requests/duplicate_logs_controller_spec.rb

12
app/controllers/duplicate_logs_controller.rb

@ -10,7 +10,10 @@ class DuplicateLogsController < ApplicationController
current_user.sales_logs.duplicate_logs(@log)
end
@all_duplicates = [@log, *@duplicate_logs]
@duplicate_check_questions = duplicate_check_question_ids.map { |question_id| @log.form.get_question(question_id, @log) }.compact
@duplicate_check_questions = duplicate_check_question_ids.map { |question_id|
question = @log.form.get_question(question_id, @log)
question if question.page.routed_to?(@log, current_user)
}.compact
else
render_not_found
end
@ -31,13 +34,14 @@ private
["owning_organisation_id",
"startdate",
"tenancycode",
@log.is_general_needs? ? "postcode_full" : nil,
@log.is_supported_housing? ? "location_id" : nil,
"postcode_full",
"scheme_id",
"location_id",
"age1",
"sex1",
"ecstat1",
@log.household_charge == 1 ? "household_charge" : nil,
!@log.is_carehome? && @log.household_charge != 1 ? "tcharge" : nil,
"tcharge",
@log.is_carehome? ? "chcharge" : nil].compact
else
%w[owning_organisation_id saledate purchid age1 sex1 ecstat1 postcode_full]

14
app/views/duplicate_logs/_duplicate_log_check_answers.erb

@ -11,6 +11,20 @@
wrapper_tag: "span",
class: "govuk-!-margin-right-4",
) %>
<% extra_value = question.get_extra_check_answer_value(@log) %>
<% if extra_value && question.answer_label(@log, current_user).present? %>
<%= simple_format(
extra_value,
wrapper_tag: "span",
class: "govuk-!-font-weight-regular app-!-colour-muted",
) %>
<% end %>
<% question.get_inferred_answers(@log).each do |inferred_answer| %>
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= inferred_answer %></span>
<% end %>
<% end %>
<% row.action(

6
spec/requests/duplicate_logs_controller_spec.rb

@ -63,7 +63,6 @@ RSpec.describe DuplicateLogsController, type: :request do
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Stock owner", count: 3)
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
expect(page).to have_content("Q7 - Tenant code", count: 3)
expect(page).to have_content("Q12 - Postcode", count: 3)
@ -71,7 +70,7 @@ RSpec.describe DuplicateLogsController, type: :request do
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3)
expect(page).to have_content("Household rent and charges", count: 3)
expect(page).to have_link("Change", count: 24)
expect(page).to have_link("Change", count: 21)
end
it "displays buttons to delete" do
@ -94,14 +93,13 @@ RSpec.describe DuplicateLogsController, type: :request do
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Owning organisation", count: 3)
expect(page).to have_content("Q1 - Sale completion date", count: 3)
expect(page).to have_content("Q2 - Purchaser code", count: 3)
expect(page).to have_content("Q20 - Lead buyer’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Q15 - Postcode", count: 3)
expect(page).to have_link("Change", count: 21)
expect(page).to have_link("Change", count: 18)
end
it "displays buttons to delete" do

Loading…
Cancel
Save