Browse Source

Add multiple partners soft validations

pull/2256/head
Kat 2 years ago
parent
commit
395fb13f54
  1. 26
      app/models/form/lettings/pages/multiple_partners_value_check.rb
  2. 24
      app/models/form/lettings/questions/multiple_partners_value_check.rb
  3. 7
      app/models/form/lettings/subsections/household_characteristics.rb
  4. 26
      app/models/form/sales/pages/multiple_partners_value_check.rb
  5. 24
      app/models/form/sales/questions/multiple_partners_value_check.rb
  6. 5
      app/models/form/sales/subsections/household_characteristics.rb
  7. 2
      app/models/validations/shared_validations.rb
  8. 4
      app/models/validations/soft_validations.rb
  9. 8
      config/locales/en.yml
  10. 91
      spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb
  11. 61
      spec/models/form/lettings/questions/multiple_partners_value_check_spec.rb
  12. 7
      spec/models/form/lettings/subsections/household_characteristics_spec.rb
  13. 91
      spec/models/form/sales/pages/multiple_partners_value_check_spec.rb
  14. 61
      spec/models/form/sales/questions/multiple_partners_value_check_spec.rb
  15. 5
      spec/models/form/sales/subsections/household_characteristics_spec.rb

26
app/models/form/lettings/pages/multiple_partners_value_check.rb

@ -0,0 +1,26 @@
class Form::Lettings::Pages::MultiplePartnersValueCheck < Form::Page
def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection)
@depends_on = [
{
"multiple_partners?" => true,
},
]
@person_index = person_index
@title_text = {
"translation" => "soft_validations.multiple_partners_lettings.title",
"arguments" => [],
}
@informative_text = {}
end
def questions
@questions ||= [
Form::Lettings::Questions::MultiplePartnersValueCheck.new(nil, nil, self, person_index: @person_index),
]
end
def interruption_screen_question_ids
%w[relat2 relat3 relat4 relat5 relat6 relat7 relat8]
end
end

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

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

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

@ -34,6 +34,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -54,6 +55,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -74,6 +76,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -94,6 +97,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -114,6 +118,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -134,6 +139,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_7_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,
@ -154,6 +160,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?),
(Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_8_multiple_partners_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),
Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self,

26
app/models/form/sales/pages/multiple_partners_value_check.rb

@ -0,0 +1,26 @@
class Form::Sales::Pages::MultiplePartnersValueCheck < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@depends_on = [
{
"multiple_partners?" => true,
},
]
@person_index = person_index
@title_text = {
"translation" => "soft_validations.multiple_partners_sales.title",
"arguments" => [],
}
@informative_text = {}
end
def questions
@questions ||= [
Form::Sales::Questions::MultiplePartnersValueCheck.new(nil, nil, self, person_index: @person_index),
]
end
def interruption_screen_question_ids
%w[relat2 relat3 relat4 relat5 relat6]
end
end

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

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

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

@ -51,6 +51,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_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::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),
@ -64,6 +65,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_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::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),
@ -77,6 +79,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_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::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),
@ -90,6 +93,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_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::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),
@ -103,6 +107,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
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::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?),
(Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_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::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),

2
app/models/validations/shared_validations.rb

@ -103,6 +103,8 @@ module Validations::SharedValidations
end
def shared_validate_partner_count(record, max_people)
return if record.form.start_year_after_2024?
partner_numbers = (2..max_people).select { |n| person_is_partner?(record["relat#{n}"]) }
if partner_numbers.count > 1
partner_numbers.each do |n|

4
app/models/validations/soft_validations.rb

@ -191,6 +191,10 @@ module Validations::SoftValidations
PHRASES_LIKELY_TO_INDICATE_EXISTING_REASON_CATEGORY_REGEX.match?(reasonother)
end
def multiple_partners?
(2..hhmemb).count { |n| public_send("relat#{n}") == "P" } > 1
end
private
def details_known_or_lead_tenant?(tenant_number)

8
config/locales/en.yml

@ -774,8 +774,14 @@ Make sure these answers are correct."
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."
partner_under_16:
partner_under_16_lettings:
title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant."
partner_under_16_sales:
title: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1."
multiple_partners_lettings:
title: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant."
multiple_partners_sales:
title: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1."
devise:
email:

91
spec/models/form/lettings/pages/multiple_partners_value_check_spec.rb

@ -0,0 +1,91 @@
require "rails_helper"
RSpec.describe Form::Lettings::Pages::MultiplePartnersValueCheck, 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) { "multiple_partners_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) { "multiple_partners_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check])
end
it "has the correct id" do
expect(page.id).to eq("multiple_partners_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "multiple_partners?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.multiple_partners_lettings.title",
"arguments" => [],
})
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[relat2 relat3 relat4 relat5 relat6 relat7 relat8])
end
end
context "with person 2" do
let(:person_index) { 2 }
let(:page_id) { "person_2_multiple_partners_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_2_multiple_partners_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "multiple_partners?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.multiple_partners_lettings.title",
"arguments" => [],
})
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[relat2 relat3 relat4 relat5 relat6 relat7 relat8])
end
end
end

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

@ -0,0 +1,61 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::MultiplePartnersValueCheck, 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("multiple_partners_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("Multiple partners 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" => [
{
"multiple_partners_value_check" => 0,
},
{
"multiple_partners_value_check" => 1,
},
],
})
end
end

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

@ -190,6 +190,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_2_known
person_2_relationship_to_lead
relationship_2_partner_under_16_value_check
relationship_2_multiple_partners_value_check
person_2_age_child
person_2_age_non_child
no_females_pregnant_household_person_2_age_value_check
@ -207,6 +208,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_3_known
person_3_relationship_to_lead
relationship_3_partner_under_16_value_check
relationship_3_multiple_partners_value_check
person_3_age_child
person_3_age_non_child
no_females_pregnant_household_person_3_age_value_check
@ -224,6 +226,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_4_known
person_4_relationship_to_lead
relationship_4_partner_under_16_value_check
relationship_4_multiple_partners_value_check
person_4_age_child
person_4_age_non_child
no_females_pregnant_household_person_4_age_value_check
@ -241,6 +244,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_5_known
person_5_relationship_to_lead
relationship_5_partner_under_16_value_check
relationship_5_multiple_partners_value_check
person_5_age_child
person_5_age_non_child
no_females_pregnant_household_person_5_age_value_check
@ -258,6 +262,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_6_known
person_6_relationship_to_lead
relationship_6_partner_under_16_value_check
relationship_6_multiple_partners_value_check
person_6_age_child
person_6_age_non_child
no_females_pregnant_household_person_6_age_value_check
@ -275,6 +280,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_7_known
person_7_relationship_to_lead
relationship_7_partner_under_16_value_check
relationship_7_multiple_partners_value_check
person_7_age_child
person_7_age_non_child
no_females_pregnant_household_person_7_age_value_check
@ -292,6 +298,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod
person_8_known
person_8_relationship_to_lead
relationship_8_partner_under_16_value_check
relationship_8_multiple_partners_value_check
person_8_age_child
person_8_age_non_child
no_females_pregnant_household_person_8_age_value_check

91
spec/models/form/sales/pages/multiple_partners_value_check_spec.rb

@ -0,0 +1,91 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::MultiplePartnersValueCheck, 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) { "multiple_partners_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) { "multiple_partners_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check])
end
it "has the correct id" do
expect(page.id).to eq("multiple_partners_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "multiple_partners?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.multiple_partners_sales.title",
"arguments" => [],
})
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[relat2 relat3 relat4 relat5 relat6])
end
end
context "with person 2" do
let(:person_index) { 2 }
let(:page_id) { "person_2_multiple_partners_value_check" }
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[multiple_partners_value_check])
end
it "has the correct id" do
expect(page.id).to eq("person_2_multiple_partners_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([{ "multiple_partners?" => true }])
end
it "has correct title_text" do
expect(page.title_text).to eq({
"translation" => "soft_validations.multiple_partners_sales.title",
"arguments" => [],
})
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[relat2 relat3 relat4 relat5 relat6])
end
end
end

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

@ -0,0 +1,61 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::MultiplePartnersValueCheck, 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("multiple_partners_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("Multiple partners 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" => [
{
"multiple_partners_value_check" => 0,
},
{
"multiple_partners_value_check" => 1,
},
],
})
end
end

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

@ -293,6 +293,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_2_known
person_2_relationship_to_buyer_1
relationship_2_partner_under_16_value_check
relationship_2_multiple_partners_value_check
relationship_2_student_not_child_value_check
person_2_age
age_2_retirement_value_check
@ -306,6 +307,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_3_known
person_3_relationship_to_buyer_1
relationship_3_partner_under_16_value_check
relationship_3_multiple_partners_value_check
relationship_3_student_not_child_value_check
person_3_age
age_3_retirement_value_check
@ -319,6 +321,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_4_known
person_4_relationship_to_buyer_1
relationship_4_partner_under_16_value_check
relationship_4_multiple_partners_value_check
relationship_4_student_not_child_value_check
person_4_age
age_4_retirement_value_check
@ -332,6 +335,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_5_known
person_5_relationship_to_buyer_1
relationship_5_partner_under_16_value_check
relationship_5_multiple_partners_value_check
relationship_5_student_not_child_value_check
person_5_age
age_5_retirement_value_check
@ -345,6 +349,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_6_known
person_6_relationship_to_buyer_1
relationship_6_partner_under_16_value_check
relationship_6_multiple_partners_value_check
relationship_6_student_not_child_value_check
person_6_age
age_6_retirement_value_check

Loading…
Cancel
Save