Browse Source

Add partner under 16 soft validation

pull/2256/head
Kat 2 years ago
parent
commit
e5e041c091
  1. 32
      app/models/form/lettings/pages/partner_under_16_value_check.rb
  2. 24
      app/models/form/lettings/questions/partner_under_16_value_check.rb
  3. 14
      app/models/form/lettings/subsections/household_characteristics.rb
  4. 32
      app/models/form/sales/pages/partner_under_16_value_check.rb
  5. 24
      app/models/form/sales/questions/partner_under_16_value_check.rb
  6. 10
      app/models/form/sales/subsections/household_characteristics.rb
  7. 11
      app/models/validations/soft_validations.rb
  8. 2
      config/locales/en.yml
  9. 255
      spec/models/form/lettings/pages/partner_under16_value_check_spec.rb
  10. 61
      spec/models/form/lettings/questions/partner_under16_value_check_spec.rb
  11. 14
      spec/models/form/lettings/subsections/household_characteristics_spec.rb
  12. 255
      spec/models/form/sales/pages/partner_under16_value_check_spec.rb
  13. 61
      spec/models/form/sales/questions/partner_under16_value_check_spec.rb
  14. 10
      spec/models/form/sales/subsections/household_characteristics_spec.rb

32
app/models/form/lettings/pages/partner_under_16_value_check.rb

@ -0,0 +1,32 @@
class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@depends_on = [
{
"person_#{person_index}_partner_under_16?" => true,
},
]
@person_index = person_index
@title_text = {
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age#{person_index}",
"label" => true,
"i18n_template" => "age",
},
],
}
@informative_text = {}
end
def questions
@questions ||= [
Form::Lettings::Questions::PartnerUnder16ValueCheck.new(nil, nil, self, person_index: @person_index),
]
end
def interruption_screen_question_ids
["age#{@person_index}", "relat#{@person_index}"]
end
end

24
app/models/form/lettings/questions/partner_under_16_value_check.rb

@ -0,0 +1,24 @@
class Form::Lettings::Questions::PartnerUnder16ValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "partner_under_16_value_check"
@check_answer_label = "Partner under 16 confirmation"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"partner_under_16_value_check" => 0,
},
{
"partner_under_16_value_check" => 1,
},
],
}
@check_answers_card_number = person_index
@header = "Are you sure this is correct?"
end
end

14
app/models/form/lettings/subsections/household_characteristics.rb

@ -33,6 +33,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new("working_situation_lead_tenant_over_retirement_value_check", nil, self), Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new("working_situation_lead_tenant_over_retirement_value_check", nil, self),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 2),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -41,6 +42,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 2), person_index: 2),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_2_under_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_2_under_retirement_value_check", nil, self, person_index: 2),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_2_over_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_2_over_retirement_value_check", nil, self, person_index: 2),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 2),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,
@ -51,6 +53,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_2_over_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_2_over_retirement_value_check", nil, self, person_index: 2),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 3),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -59,6 +62,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 3), person_index: 3),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_3_under_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_3_under_retirement_value_check", nil, self, person_index: 3),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_3_over_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_3_over_retirement_value_check", nil, self, person_index: 3),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 3),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,
@ -69,6 +73,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_3_over_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_3_over_retirement_value_check", nil, self, person_index: 3),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 4),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -77,6 +82,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 4), person_index: 4),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_4_under_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_4_under_retirement_value_check", nil, self, person_index: 4),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_4_over_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_4_over_retirement_value_check", nil, self, person_index: 4),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 4),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,
@ -87,6 +93,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_4_over_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_4_over_retirement_value_check", nil, self, person_index: 4),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 5),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -95,6 +102,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 5), person_index: 5),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_5_under_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_5_under_retirement_value_check", nil, self, person_index: 5),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_5_over_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_5_over_retirement_value_check", nil, self, person_index: 5),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 5),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,
@ -105,6 +113,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_5_over_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_5_over_retirement_value_check", nil, self, person_index: 5),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 6),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -113,6 +122,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 6), person_index: 6),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_6_under_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_6_under_retirement_value_check", nil, self, person_index: 6),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_6_over_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_6_over_retirement_value_check", nil, self, person_index: 6),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 6),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,
@ -123,6 +133,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_6_over_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_6_over_retirement_value_check", nil, self, person_index: 6),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 7),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -131,6 +142,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 7), person_index: 7),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_7_under_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_7_under_retirement_value_check", nil, self, person_index: 7),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_7_over_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_7_over_retirement_value_check", nil, self, person_index: 7),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 7),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,
@ -141,6 +153,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_7_over_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_7_over_retirement_value_check", nil, self, person_index: 7),
Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 8),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8, person_type: "child"),
Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -149,6 +162,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
person_index: 8), person_index: 8),
Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_8_under_retirement_value_check", nil, self, person_index: 8), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_8_under_retirement_value_check", nil, self, person_index: 8),
Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_8_over_retirement_value_check", nil, self, person_index: 8), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_8_over_retirement_value_check", nil, self, person_index: 8),
(Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?),
Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 8),
Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self,

32
app/models/form/sales/pages/partner_under_16_value_check.rb

@ -0,0 +1,32 @@
class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@depends_on = [
{
"person_#{person_index}_partner_under_16?" => true,
},
]
@person_index = person_index
@title_text = {
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age#{person_index}",
"label" => true,
"i18n_template" => "age",
},
],
}
@informative_text = {}
end
def questions
@questions ||= [
Form::Sales::Questions::PartnerUnder16ValueCheck.new(nil, nil, self, person_index: @person_index),
]
end
def interruption_screen_question_ids
["age#{@person_index}", "relat#{@person_index}"]
end
end

24
app/models/form/sales/questions/partner_under_16_value_check.rb

@ -0,0 +1,24 @@
class Form::Sales::Questions::PartnerUnder16ValueCheck < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@id = "partner_under_16_value_check"
@check_answer_label = "Partner under 16 confirmation"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"partner_under_16_value_check" => 0,
},
{
"partner_under_16_value_check" => 1,
},
],
}
@check_answers_card_number = person_index
@header = "Are you sure this is correct?"
end
end

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

@ -50,10 +50,12 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property_joint_purchase", nil, self, joint_purchase: true),
Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2), Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_2_student_not_child_value_check", nil, self, person_index: 2),
Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 2), Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 2),
Form::Sales::Pages::RetirementValueCheck.new("age_2_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("age_2_retirement_value_check", nil, self, person_index: 2),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_2_student_not_child_value_check", nil, self, person_index: 2),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?),
Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 2), Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 2),
Form::Sales::Pages::RetirementValueCheck.new("gender_2_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("gender_2_retirement_value_check", nil, self, person_index: 2),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 2), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 2),
@ -61,10 +63,12 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_2_student_not_child_value_check", nil, self, person_index: 2),
Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_3_student_not_child_value_check", nil, self, person_index: 3),
Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 3), Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 3),
Form::Sales::Pages::RetirementValueCheck.new("age_3_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("age_3_retirement_value_check", nil, self, person_index: 3),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_3_student_not_child_value_check", nil, self, person_index: 3),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?),
Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 3), Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 3),
Form::Sales::Pages::RetirementValueCheck.new("gender_3_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("gender_3_retirement_value_check", nil, self, person_index: 3),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 3),
@ -72,10 +76,12 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_3_student_not_child_value_check", nil, self, person_index: 3),
Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_4_student_not_child_value_check", nil, self, person_index: 4),
Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 4),
Form::Sales::Pages::RetirementValueCheck.new("age_4_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("age_4_retirement_value_check", nil, self, person_index: 4),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_4_student_not_child_value_check", nil, self, person_index: 4),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?),
Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 4), Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 4),
Form::Sales::Pages::RetirementValueCheck.new("gender_4_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("gender_4_retirement_value_check", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 4),
@ -83,10 +89,12 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_4_student_not_child_value_check", nil, self, person_index: 4),
Form::Sales::Pages::PersonKnown.new("person_5_known", nil, self, person_index: 5), Form::Sales::Pages::PersonKnown.new("person_5_known", nil, self, person_index: 5),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_5_student_not_child_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonAge.new("person_5_age", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_5_age", nil, self, person_index: 5),
Form::Sales::Pages::RetirementValueCheck.new("age_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("age_5_retirement_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_5_student_not_child_value_check", nil, self, person_index: 5),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?),
Form::Sales::Pages::PersonGenderIdentity.new("person_5_gender_identity", nil, self, person_index: 5), Form::Sales::Pages::PersonGenderIdentity.new("person_5_gender_identity", nil, self, person_index: 5),
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),
@ -94,10 +102,12 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_5_student_not_child_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonKnown.new("person_6_known", nil, self, person_index: 6), 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::PersonRelationshipToBuyer1.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_6_student_not_child_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_6_student_not_child_value_check", nil, self, person_index: 6),
Form::Sales::Pages::PersonAge.new("person_6_age", 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::RetirementValueCheck.new("age_6_retirement_value_check", nil, self, person_index: 6),
Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_6_student_not_child_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_6_student_not_child_value_check", nil, self, person_index: 6),
(Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?),
Form::Sales::Pages::PersonGenderIdentity.new("person_6_gender_identity", 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::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::PersonWorkingSituation.new("person_6_working_situation", nil, self, person_index: 6),

11
app/models/validations/soft_validations.rb

@ -62,6 +62,9 @@ module Validations::SoftValidations
define_method("person_#{person_num}_not_retired_over_soft_max_age?") do define_method("person_#{person_num}_not_retired_over_soft_max_age?") do
not_retired_over_soft_max_age?(person_num) not_retired_over_soft_max_age?(person_num)
end end
define_method("person_#{person_num}_partner_under_16?") do
partner_under_16?(person_num)
end
end end
def no_females_in_a_pregnant_household? def no_females_in_a_pregnant_household?
@ -234,4 +237,12 @@ private
%w[M X].include?(gender) && !tenant_retired_or_prefers_not_say && age > retirement_age_for_person(person_num) || %w[M X].include?(gender) && !tenant_retired_or_prefers_not_say && age > retirement_age_for_person(person_num) ||
gender == "F" && !tenant_retired_or_prefers_not_say && age > 60 gender == "F" && !tenant_retired_or_prefers_not_say && age > 60
end end
def partner_under_16?(person_num)
age = public_send("age#{person_num}")
relationship = public_send("relat#{person_num}")
return unless age && relationship
age < 16 && relationship == "P"
end
end end

2
config/locales/en.yml

@ -774,6 +774,8 @@ Make sure these answers are correct."
no_address_found: no_address_found:
title_text: "No address found" title_text: "No address found"
informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually."
partner_under_16:
title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
devise: devise:
email: email:

255
spec/models/form/lettings/pages/partner_under16_value_check_spec.rb

@ -0,0 +1,255 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::PartnerUnder16ValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:person_index) { 1 }
let(:page_id) { "partner_under_16_value_check" }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
context "with person 1" do
let(:person_index) { 1 }
let(:page_id) { "partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_1_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age1",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age1 relat1])
end
end
context "with person 2" do
let(:person_index) { 2 }
let(:page_id) { "person_2_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_2_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_2_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age2",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age2 relat2])
end
end
context "with person 3" do
let(:person_index) { 3 }
let(:page_id) { "person_3_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_3_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_3_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age3",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age3 relat3])
end
end
context "with person 4" do
let(:person_index) { 4 }
let(:page_id) { "person_4_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_4_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_4_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age4",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age4 relat4])
end
end
context "with person 5" do
let(:person_index) { 5 }
let(:page_id) { "person_5_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_5_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_5_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age5",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age5 relat5])
end
end
context "with person 6" do
let(:person_index) { 6 }
let(:page_id) { "person_6_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_6_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_6_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_lettings.title",
"arguments" => [
{
"key" => "age6",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age6 relat6])
end
end
end

61
spec/models/form/lettings/questions/partner_under16_value_check_spec.rb

@ -0,0 +1,61 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::PartnerUnder16ValueCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("partner_under_16_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Partner under 16 confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has a correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"partner_under_16_value_check" => 0,
},
{
"partner_under_16_value_check" => 1,
},
],
})
end
end

14
spec/models/form/lettings/subsections/household_characteristics_spec.rb

@ -189,12 +189,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_lead_tenant_over_retirement_value_check working_situation_lead_tenant_over_retirement_value_check
person_2_known person_2_known
person_2_relationship_to_lead person_2_relationship_to_lead
relationship_2_partner_under_16_value_check
person_2_age_child person_2_age_child
person_2_age_non_child person_2_age_non_child
no_females_pregnant_household_person_2_age_value_check no_females_pregnant_household_person_2_age_value_check
females_in_soft_age_range_in_pregnant_household_person_2_age_value_check females_in_soft_age_range_in_pregnant_household_person_2_age_value_check
age_2_under_retirement_value_check age_2_under_retirement_value_check
age_2_over_retirement_value_check age_2_over_retirement_value_check
age_2_partner_under_16_value_check
person_2_gender_identity person_2_gender_identity
no_females_pregnant_household_person_2_value_check no_females_pregnant_household_person_2_value_check
females_in_soft_age_range_in_pregnant_household_person_2_value_check females_in_soft_age_range_in_pregnant_household_person_2_value_check
@ -204,12 +206,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_2_over_retirement_value_check working_situation_2_over_retirement_value_check
person_3_known person_3_known
person_3_relationship_to_lead person_3_relationship_to_lead
relationship_3_partner_under_16_value_check
person_3_age_child person_3_age_child
person_3_age_non_child person_3_age_non_child
no_females_pregnant_household_person_3_age_value_check no_females_pregnant_household_person_3_age_value_check
females_in_soft_age_range_in_pregnant_household_person_3_age_value_check females_in_soft_age_range_in_pregnant_household_person_3_age_value_check
age_3_under_retirement_value_check age_3_under_retirement_value_check
age_3_over_retirement_value_check age_3_over_retirement_value_check
age_3_partner_under_16_value_check
person_3_gender_identity person_3_gender_identity
no_females_pregnant_household_person_3_value_check no_females_pregnant_household_person_3_value_check
females_in_soft_age_range_in_pregnant_household_person_3_value_check females_in_soft_age_range_in_pregnant_household_person_3_value_check
@ -219,12 +223,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_3_over_retirement_value_check working_situation_3_over_retirement_value_check
person_4_known person_4_known
person_4_relationship_to_lead person_4_relationship_to_lead
relationship_4_partner_under_16_value_check
person_4_age_child person_4_age_child
person_4_age_non_child person_4_age_non_child
no_females_pregnant_household_person_4_age_value_check no_females_pregnant_household_person_4_age_value_check
females_in_soft_age_range_in_pregnant_household_person_4_age_value_check females_in_soft_age_range_in_pregnant_household_person_4_age_value_check
age_4_under_retirement_value_check age_4_under_retirement_value_check
age_4_over_retirement_value_check age_4_over_retirement_value_check
age_4_partner_under_16_value_check
person_4_gender_identity person_4_gender_identity
no_females_pregnant_household_person_4_value_check no_females_pregnant_household_person_4_value_check
females_in_soft_age_range_in_pregnant_household_person_4_value_check females_in_soft_age_range_in_pregnant_household_person_4_value_check
@ -234,12 +240,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_4_over_retirement_value_check working_situation_4_over_retirement_value_check
person_5_known person_5_known
person_5_relationship_to_lead person_5_relationship_to_lead
relationship_5_partner_under_16_value_check
person_5_age_child person_5_age_child
person_5_age_non_child person_5_age_non_child
no_females_pregnant_household_person_5_age_value_check no_females_pregnant_household_person_5_age_value_check
females_in_soft_age_range_in_pregnant_household_person_5_age_value_check females_in_soft_age_range_in_pregnant_household_person_5_age_value_check
age_5_under_retirement_value_check age_5_under_retirement_value_check
age_5_over_retirement_value_check age_5_over_retirement_value_check
age_5_partner_under_16_value_check
person_5_gender_identity person_5_gender_identity
no_females_pregnant_household_person_5_value_check no_females_pregnant_household_person_5_value_check
females_in_soft_age_range_in_pregnant_household_person_5_value_check females_in_soft_age_range_in_pregnant_household_person_5_value_check
@ -249,12 +257,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_5_over_retirement_value_check working_situation_5_over_retirement_value_check
person_6_known person_6_known
person_6_relationship_to_lead person_6_relationship_to_lead
relationship_6_partner_under_16_value_check
person_6_age_child person_6_age_child
person_6_age_non_child person_6_age_non_child
no_females_pregnant_household_person_6_age_value_check no_females_pregnant_household_person_6_age_value_check
females_in_soft_age_range_in_pregnant_household_person_6_age_value_check females_in_soft_age_range_in_pregnant_household_person_6_age_value_check
age_6_under_retirement_value_check age_6_under_retirement_value_check
age_6_over_retirement_value_check age_6_over_retirement_value_check
age_6_partner_under_16_value_check
person_6_gender_identity person_6_gender_identity
no_females_pregnant_household_person_6_value_check no_females_pregnant_household_person_6_value_check
females_in_soft_age_range_in_pregnant_household_person_6_value_check females_in_soft_age_range_in_pregnant_household_person_6_value_check
@ -264,12 +274,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_6_over_retirement_value_check working_situation_6_over_retirement_value_check
person_7_known person_7_known
person_7_relationship_to_lead person_7_relationship_to_lead
relationship_7_partner_under_16_value_check
person_7_age_child person_7_age_child
person_7_age_non_child person_7_age_non_child
no_females_pregnant_household_person_7_age_value_check no_females_pregnant_household_person_7_age_value_check
females_in_soft_age_range_in_pregnant_household_person_7_age_value_check females_in_soft_age_range_in_pregnant_household_person_7_age_value_check
age_7_under_retirement_value_check age_7_under_retirement_value_check
age_7_over_retirement_value_check age_7_over_retirement_value_check
age_7_partner_under_16_value_check
person_7_gender_identity person_7_gender_identity
no_females_pregnant_household_person_7_value_check no_females_pregnant_household_person_7_value_check
females_in_soft_age_range_in_pregnant_household_person_7_value_check females_in_soft_age_range_in_pregnant_household_person_7_value_check
@ -279,12 +291,14 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
working_situation_7_over_retirement_value_check working_situation_7_over_retirement_value_check
person_8_known person_8_known
person_8_relationship_to_lead person_8_relationship_to_lead
relationship_8_partner_under_16_value_check
person_8_age_child person_8_age_child
person_8_age_non_child person_8_age_non_child
no_females_pregnant_household_person_8_age_value_check no_females_pregnant_household_person_8_age_value_check
females_in_soft_age_range_in_pregnant_household_person_8_age_value_check females_in_soft_age_range_in_pregnant_household_person_8_age_value_check
age_8_under_retirement_value_check age_8_under_retirement_value_check
age_8_over_retirement_value_check age_8_over_retirement_value_check
age_8_partner_under_16_value_check
person_8_gender_identity person_8_gender_identity
no_females_pregnant_household_person_8_value_check no_females_pregnant_household_person_8_value_check
females_in_soft_age_range_in_pregnant_household_person_8_value_check females_in_soft_age_range_in_pregnant_household_person_8_value_check

255
spec/models/form/sales/pages/partner_under16_value_check_spec.rb

@ -0,0 +1,255 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
let(:person_index) { 1 }
let(:page_id) { "partner_under_16_value_check" }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has the correct header" do
expect(page.header).to be_nil
end
it "has the correct description" do
expect(page.description).to be_nil
end
it "is interruption screen page" do
expect(page.interruption_screen?).to eq(true)
end
context "with person 1" do
let(:person_index) { 1 }
let(:page_id) { "partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_1_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age1",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age1 relat1])
end
end
context "with person 2" do
let(:person_index) { 2 }
let(:page_id) { "person_2_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_2_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_2_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age2",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age2 relat2])
end
end
context "with person 3" do
let(:person_index) { 3 }
let(:page_id) { "person_3_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_3_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_3_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age3",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age3 relat3])
end
end
context "with person 4" do
let(:person_index) { 4 }
let(:page_id) { "person_4_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_4_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_4_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age4",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age4 relat4])
end
end
context "with person 5" do
let(:person_index) { 5 }
let(:page_id) { "person_5_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_5_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_5_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age5",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age5 relat5])
end
end
context "with person 6" do
let(:person_index) { 6 }
let(:page_id) { "person_6_partner_under_16_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[partner_under_16_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_6_partner_under_16_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_6_partner_under_16?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.partner_under_16_sales.title",
"arguments" => [
{
"key" => "age6",
"label" => true,
"i18n_template" => "age",
},
],
})
end
it "has correct informative_text" do
expect(page.informative_text).to eq({})
end
it "has correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[age6 relat6])
end
end
end

61
spec/models/form/sales/questions/partner_under16_value_check_spec.rb

@ -0,0 +1,61 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PartnerUnder16ValueCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page, person_index: 1) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("partner_under_16_value_check")
end
it "has the correct header" do
expect(question.header).to eq("Are you sure this is correct?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Partner under 16 confirmation")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to be_nil
end
it "has a correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(1)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"partner_under_16_value_check" => 0,
},
{
"partner_under_16_value_check" => 1,
},
],
})
end
end

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

@ -292,10 +292,12 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
number_of_others_in_property_joint_purchase 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
relationship_2_partner_under_16_value_check
relationship_2_student_not_child_value_check relationship_2_student_not_child_value_check
person_2_age person_2_age
age_2_retirement_value_check age_2_retirement_value_check
age_2_student_not_child_value_check age_2_student_not_child_value_check
age_2_partner_under_16_value_check
person_2_gender_identity person_2_gender_identity
gender_2_retirement_value_check gender_2_retirement_value_check
person_2_working_situation person_2_working_situation
@ -303,10 +305,12 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_2_student_not_child_value_check working_situation_2_student_not_child_value_check
person_3_known person_3_known
person_3_relationship_to_buyer_1 person_3_relationship_to_buyer_1
relationship_3_partner_under_16_value_check
relationship_3_student_not_child_value_check relationship_3_student_not_child_value_check
person_3_age person_3_age
age_3_retirement_value_check age_3_retirement_value_check
age_3_student_not_child_value_check age_3_student_not_child_value_check
age_3_partner_under_16_value_check
person_3_gender_identity person_3_gender_identity
gender_3_retirement_value_check gender_3_retirement_value_check
person_3_working_situation person_3_working_situation
@ -314,10 +318,12 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_3_student_not_child_value_check working_situation_3_student_not_child_value_check
person_4_known person_4_known
person_4_relationship_to_buyer_1 person_4_relationship_to_buyer_1
relationship_4_partner_under_16_value_check
relationship_4_student_not_child_value_check relationship_4_student_not_child_value_check
person_4_age person_4_age
age_4_retirement_value_check age_4_retirement_value_check
age_4_student_not_child_value_check age_4_student_not_child_value_check
age_4_partner_under_16_value_check
person_4_gender_identity person_4_gender_identity
gender_4_retirement_value_check gender_4_retirement_value_check
person_4_working_situation person_4_working_situation
@ -325,10 +331,12 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_4_student_not_child_value_check working_situation_4_student_not_child_value_check
person_5_known person_5_known
person_5_relationship_to_buyer_1 person_5_relationship_to_buyer_1
relationship_5_partner_under_16_value_check
relationship_5_student_not_child_value_check relationship_5_student_not_child_value_check
person_5_age person_5_age
age_5_retirement_value_check age_5_retirement_value_check
age_5_student_not_child_value_check age_5_student_not_child_value_check
age_5_partner_under_16_value_check
person_5_gender_identity person_5_gender_identity
gender_5_retirement_value_check gender_5_retirement_value_check
person_5_working_situation person_5_working_situation
@ -336,10 +344,12 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
working_situation_5_student_not_child_value_check working_situation_5_student_not_child_value_check
person_6_known person_6_known
person_6_relationship_to_buyer_1 person_6_relationship_to_buyer_1
relationship_6_partner_under_16_value_check
relationship_6_student_not_child_value_check relationship_6_student_not_child_value_check
person_6_age person_6_age
age_6_retirement_value_check age_6_retirement_value_check
age_6_student_not_child_value_check age_6_student_not_child_value_check
age_6_partner_under_16_value_check
person_6_gender_identity person_6_gender_identity
gender_6_retirement_value_check gender_6_retirement_value_check
person_6_working_situation person_6_working_situation

Loading…
Cancel
Save