Browse Source

Add person 6 questions and refactor check_answers_card_title

pull/1297/head
Kat 3 years ago
parent
commit
bb8a95decf
  1. 17
      app/components/check_answers_summary_list_card_component.rb
  2. 8
      app/models/form/sales/subsections/household_characteristics.rb
  3. 1
      app/views/form/headers/_person_6_known_page.erb
  4. 24
      spec/models/form/sales/subsections/household_characteristics_spec.rb

17
app/components/check_answers_summary_list_card_component.rb

@ -18,22 +18,11 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
end end
def check_answers_card_title(question) def check_answers_card_title(question)
if question.form.type == "lettings" return "Lead tenant" if question.form.type == "lettings" && question.check_answers_card_number == 1
case question.check_answers_card_number return "Buyer #{question.check_answers_card_number}" if question.check_answers_card_number <= number_of_buyers
when 1
"Lead tenant"
when 2..8
"Person #{question.check_answers_card_number}"
end
else
case question.check_answers_card_number
when 1..number_of_buyers
"Buyer #{question.check_answers_card_number}"
when (number_of_buyers + 1)..(number_of_buyers + 4)
"Person #{question.check_answers_card_number}" "Person #{question.check_answers_card_number}"
end end
end
end
private private

8
app/models/form/sales/subsections/household_characteristics.rb

@ -71,6 +71,14 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::RetirementValueCheck.new("gender_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("gender_5_retirement_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("working_situation_5_retirement_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonKnown.new("person_6_known", nil, self, person_index: 6),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6),
Form::Sales::Pages::PersonAge.new("person_6_age", nil, self, person_index: 6),
Form::Sales::Pages::RetirementValueCheck.new("age_6_retirement_value_check", nil, self, person_index: 6),
Form::Sales::Pages::PersonGenderIdentity.new("person_6_gender_identity", nil, self, person_index: 6),
Form::Sales::Pages::RetirementValueCheck.new("gender_6_retirement_value_check", nil, self, person_index: 6),
Form::Sales::Pages::PersonWorkingSituation.new("person_6_working_situation", nil, self, person_index: 6),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_6_retirement_value_check", nil, self, person_index: 6),
].flatten.compact ].flatten.compact
end end

1
app/views/form/headers/_person_6_known_page.erb

@ -0,0 +1 @@
You have given us the details for <%= log.joint_purchase? ? 3 : 4 %> of the <%= log.hholdcount %> other people in the household

24
spec/models/form/sales/subsections/household_characteristics_spec.rb

@ -45,17 +45,12 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
age_2_buyer_retirement_value_check age_2_buyer_retirement_value_check
buyer_2_gender_identity buyer_2_gender_identity
gender_2_buyer_retirement_value_check gender_2_buyer_retirement_value_check
buyer_2_ethnic_group
buyer_2_ethnic_background_black
buyer_2_ethnic_background_asian
buyer_2_ethnic_background_arab
buyer_2_ethnic_background_mixed
buyer_2_ethnic_background_white
buyer_2_working_situation buyer_2_working_situation
working_situation_2_retirement_value_check_joint_purchase working_situation_2_retirement_value_check_joint_purchase
working_situation_buyer_2_income_value_check working_situation_buyer_2_income_value_check
buyer_2_live_in_property buyer_2_live_in_property
number_of_others_in_property number_of_others_in_property
number_of_others_in_property_joint_purchase
person_2_known person_2_known
person_2_relationship_to_buyer_1 person_2_relationship_to_buyer_1
person_2_age person_2_age
@ -88,6 +83,14 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
gender_5_retirement_value_check gender_5_retirement_value_check
person_5_working_situation person_5_working_situation
working_situation_5_retirement_value_check working_situation_5_retirement_value_check
person_6_known
person_6_relationship_to_buyer_1
person_6_age
age_6_retirement_value_check
person_6_gender_identity
gender_6_retirement_value_check
person_6_working_situation
working_situation_6_retirement_value_check
], ],
) )
end end
@ -137,6 +140,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_buyer_2_income_value_check working_situation_buyer_2_income_value_check
buyer_2_live_in_property buyer_2_live_in_property
number_of_others_in_property number_of_others_in_property
number_of_others_in_property_joint_purchase
person_2_known person_2_known
person_2_relationship_to_buyer_1 person_2_relationship_to_buyer_1
person_2_age person_2_age
@ -169,6 +173,14 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
gender_5_retirement_value_check gender_5_retirement_value_check
person_5_working_situation person_5_working_situation
working_situation_5_retirement_value_check working_situation_5_retirement_value_check
person_6_known
person_6_relationship_to_buyer_1
person_6_age
age_6_retirement_value_check
person_6_gender_identity
gender_6_retirement_value_check
person_6_working_situation
working_situation_6_retirement_value_check
], ],
) )
end end

Loading…
Cancel
Save