diff --git a/app/models/form/sales/pages/retirement_value_check.rb b/app/models/form/sales/pages/retirement_value_check.rb index 6e38630b6..ae8389acf 100644 --- a/app/models/form/sales/pages/retirement_value_check.rb +++ b/app/models/form/sales/pages/retirement_value_check.rb @@ -1,9 +1,10 @@ -class Form::Sales::Pages::RetirementValueCheck < ::Form::Page +class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person def initialize(id, hsh, subsection, person_index:) - super(id, hsh, subsection) + super @depends_on = [ { "person_#{person_index}_retired_under_soft_min_age?" => true, + "jointpur" => joint_purchase? ? 1 : 2, }, ] @person_index = person_index diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index cfddcc540..e99d85f08 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -12,8 +12,10 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::PrivacyNotice.new(nil, nil, self), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("person_1_age_retirement_value_check", nil, self, person_index: 1), + Form::Sales::Pages::RetirementValueCheck.new("person_1_age_retirement_value_check_joint_purchase", nil, self, person_index: 1), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("person_1_gender_retirement_value_check", nil, self, person_index: 1), + Form::Sales::Pages::RetirementValueCheck.new("person_1_gender_retirement_value_check_joint_purchase", nil, self, person_index: 1), Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundAsian.new(nil, nil, self), @@ -23,15 +25,19 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Nationality1.new(nil, nil, self), Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("person_1_working_situation_retirement_value_check", nil, self, person_index: 1), + Form::Sales::Pages::RetirementValueCheck.new("person_1_working_situation_retirement_value_check_joint_purchase", nil, self, person_index: 1), Form::Sales::Pages::Buyer1IncomeValueCheck.new("working_situation_buyer_1_income_value_check", nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Age2.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("person_2_age_retirement_value_check", nil, self, person_index: 2), + Form::Sales::Pages::RetirementValueCheck.new("person_2_age_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::GenderIdentity2.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("person_2_gender_retirement_value_check", nil, self, person_index: 2), + Form::Sales::Pages::RetirementValueCheck.new("person_2_gender_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("person_2_working_situation_retirement_value_check", nil, self, person_index: 2), + Form::Sales::Pages::RetirementValueCheck.new("person_2_working_situation_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self), Form::Sales::Pages::PersonKnown.new("person_1_known", nil, self, person_index: 2), @@ -39,53 +45,65 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1", nil, self, person_index: 2), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 3), Form::Sales::Pages::PersonAge.new("person_1_age", nil, self, person_index: 2), + Form::Sales::Pages::RetirementValueCheck.new("person_3_age_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonAge.new("person_1_age_joint_purchase", nil, self, person_index: 3), - Form::Sales::Pages::RetirementValueCheck.new("person_3_age_retirement_value_check", nil, self, person_index: 3), + Form::Sales::Pages::RetirementValueCheck.new("person_3_age_retirement_value_check_joint_purchase", nil, self, person_index: 3), Form::Sales::Pages::PersonGenderIdentity.new("person_1_gender_identity", nil, self, person_index: 2), + Form::Sales::Pages::RetirementValueCheck.new("person_3_gender_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonGenderIdentity.new("person_1_gender_identity_joint_purchase", nil, self, person_index: 3), - Form::Sales::Pages::RetirementValueCheck.new("person_3_gender_retirement_value_check", nil, self, person_index: 3), + Form::Sales::Pages::RetirementValueCheck.new("person_3_gender_retirement_value_check_joint_purchase", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation", nil, self, person_index: 2), + Form::Sales::Pages::RetirementValueCheck.new("person_3_working_situation_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation_joint_purchase", nil, self, person_index: 3), - Form::Sales::Pages::RetirementValueCheck.new("person_3_working_situation_retirement_value_check", nil, self, person_index: 3), + Form::Sales::Pages::RetirementValueCheck.new("person_3_working_situation_retirement_value_check_joint_purchase", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_2_known_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 3), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 3), + Form::Sales::Pages::RetirementValueCheck.new("person_4_age_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonAge.new("person_2_age_joint_purchase", nil, self, person_index: 4), - Form::Sales::Pages::RetirementValueCheck.new("person_4_age_retirement_value_check", nil, self, person_index: 4), + Form::Sales::Pages::RetirementValueCheck.new("person_4_age_retirement_value_check_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 3), + Form::Sales::Pages::RetirementValueCheck.new("person_4_gender_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity_joint_purchase", nil, self, person_index: 4), - Form::Sales::Pages::RetirementValueCheck.new("person_4_gender_retirement_value_check", nil, self, person_index: 4), + Form::Sales::Pages::RetirementValueCheck.new("person_4_gender_retirement_value_check_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 3), + Form::Sales::Pages::RetirementValueCheck.new("person_4_working_situation_retirement_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation_joint_purchase", nil, self, person_index: 4), - Form::Sales::Pages::RetirementValueCheck.new("person_4_working_situation_retirement_value_check", nil, self, person_index: 4), + Form::Sales::Pages::RetirementValueCheck.new("person_4_working_situation_retirement_value_check_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_3_known_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 4), + Form::Sales::Pages::RetirementValueCheck.new("person_5_age_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_3_age_joint_purchase", nil, self, person_index: 5), - Form::Sales::Pages::RetirementValueCheck.new("person_5_age_retirement_value_check", nil, self, person_index: 5), + Form::Sales::Pages::RetirementValueCheck.new("person_5_age_retirement_value_check_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 4), + Form::Sales::Pages::RetirementValueCheck.new("person_5_gender_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity_joint_purchase", nil, self, person_index: 5), - Form::Sales::Pages::RetirementValueCheck.new("person_5_gender_retirement_value_check", nil, self, person_index: 5), + Form::Sales::Pages::RetirementValueCheck.new("person_5_gender_retirement_value_check_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 4), + Form::Sales::Pages::RetirementValueCheck.new("person_5_working_situation_retirement_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation_joint_purchase", nil, self, person_index: 5), - Form::Sales::Pages::RetirementValueCheck.new("person_5_working_situation_retirement_value_check", nil, self, person_index: 5), + Form::Sales::Pages::RetirementValueCheck.new("person_5_working_situation_retirement_value_check_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 5), Form::Sales::Pages::PersonKnown.new("person_4_known_joint_purchase", nil, self, person_index: 6), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 6), Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 5), + Form::Sales::Pages::RetirementValueCheck.new("person_6_age_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_4_age_joint_purchase", nil, self, person_index: 6), - Form::Sales::Pages::RetirementValueCheck.new("person_6_age_retirement_value_check", nil, self, person_index: 6), + Form::Sales::Pages::RetirementValueCheck.new("person_6_age_retirement_value_check_joint_purchase", nil, self, person_index: 6), Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 5), + Form::Sales::Pages::RetirementValueCheck.new("person_6_gender_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity_joint_purchase", nil, self, person_index: 6), - Form::Sales::Pages::RetirementValueCheck.new("person_6_gender_retirement_value_check", nil, self, person_index: 6), + Form::Sales::Pages::RetirementValueCheck.new("person_6_gender_retirement_value_check_joint_purchase", nil, self, person_index: 6), Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 5), + Form::Sales::Pages::RetirementValueCheck.new("person_6_working_situation_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation_joint_purchase", nil, self, person_index: 6), - Form::Sales::Pages::RetirementValueCheck.new("person_6_working_situation_retirement_value_check", nil, self, person_index: 6), + Form::Sales::Pages::RetirementValueCheck.new("person_6_working_situation_retirement_value_check_joint_purchase", nil, self, person_index: 6), ] end end diff --git a/spec/models/form/sales/pages/retirement_value_check_spec.rb b/spec/models/form/sales/pages/retirement_value_check_spec.rb index 06993bc05..9c04ef25c 100644 --- a/spec/models/form/sales/pages/retirement_value_check_spec.rb +++ b/spec/models/form/sales/pages/retirement_value_check_spec.rb @@ -21,291 +21,583 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do expect(page.description).to be_nil end - context "with person 1" do - let(:person_index) { 1 } - let(:page_id) { "person_1_retirement_value_check" } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) - end - - it "has the correct id" do - expect(page.id).to eq("person_1_retirement_value_check") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "person_1_retired_under_soft_min_age?" => true }]) - end - - it "has correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", - "arguments" => [ - { - "key" => "retirement_age_for_person_1", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - - it "has correct informative_text" do - expect(page.informative_text).to eq({ - "translation" => "soft_validations.retirement.min.hint_text", - "arguments" => [ - { - "key" => "plural_gender_for_person_1", - "label" => false, - "i18n_template" => "gender", - }, - { - "key" => "retirement_age_for_person_1", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - end - - context "with person 2" do - let(:person_index) { 2 } - let(:page_id) { "person_2_retirement_value_check" } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) - end - - it "has the correct id" do - expect(page.id).to eq("person_2_retirement_value_check") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "person_2_retired_under_soft_min_age?" => true }]) - end - - it "has correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", - "arguments" => [ - { - "key" => "retirement_age_for_person_2", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - - it "has correct informative_text" do - expect(page.informative_text).to eq({ - "translation" => "soft_validations.retirement.min.hint_text", - "arguments" => [ - { - "key" => "plural_gender_for_person_2", - "label" => false, - "i18n_template" => "gender", - }, - { - "key" => "retirement_age_for_person_2", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - end - - context "with person 3" do - let(:person_index) { 3 } - let(:page_id) { "person_3_retirement_value_check" } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) - end - - it "has the correct id" do - expect(page.id).to eq("person_3_retirement_value_check") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "person_3_retired_under_soft_min_age?" => true }]) + context "with joint purchase" do + context "with person 1" do + let(:person_index) { 1 } + let(:page_id) { "person_1_retirement_value_check_joint_purchase" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_1_retirement_value_check_joint_purchase") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_1_retired_under_soft_min_age?" => true, "jointpur" => 1 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_1", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", - "arguments" => [ - { - "key" => "retirement_age_for_person_3", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - - it "has correct informative_text" do - expect(page.informative_text).to eq({ - "translation" => "soft_validations.retirement.min.hint_text", - "arguments" => [ - { - "key" => "plural_gender_for_person_3", - "label" => false, - "i18n_template" => "gender", - }, - { - "key" => "retirement_age_for_person_3", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - end - - context "with person 4" do - let(:person_index) { 4 } - let(:page_id) { "person_4_retirement_value_check" } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_retirement_value_check_joint_purchase" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_retirement_value_check_joint_purchase") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_2_retired_under_soft_min_age?" => true, "jointpur" => 1 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_2", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has the correct id" do - expect(page.id).to eq("person_4_retirement_value_check") + context "with person 3" do + let(:person_index) { 3 } + let(:page_id) { "person_3_retirement_value_check_joint_purchase" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_retirement_value_check_joint_purchase") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_3_retired_under_soft_min_age?" => true, "jointpur" => 1 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_3", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "person_4_retired_under_soft_min_age?" => true }]) + context "with person 4" do + let(:person_index) { 4 } + let(:page_id) { "person_4_retirement_value_check_joint_purchase" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_4_retirement_value_check_joint_purchase") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_4_retired_under_soft_min_age?" => true, "jointpur" => 1 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_4", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_4", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_4", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", - "arguments" => [ - { - "key" => "retirement_age_for_person_4", - "label" => false, - "i18n_template" => "age", - }, - ], - }) + context "with person 5" do + let(:person_index) { 5 } + let(:page_id) { "person_5_retirement_value_check_joint_purchase" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_5_retirement_value_check_joint_purchase") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_5_retired_under_soft_min_age?" => true, "jointpur" => 1 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_5", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_5", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_5", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct informative_text" do - expect(page.informative_text).to eq({ - "translation" => "soft_validations.retirement.min.hint_text", - "arguments" => [ - { - "key" => "plural_gender_for_person_4", - "label" => false, - "i18n_template" => "gender", - }, - { - "key" => "retirement_age_for_person_4", - "label" => false, - "i18n_template" => "age", - }, - ], - }) + context "with person 6" do + let(:person_index) { 6 } + let(:page_id) { "person_6_retirement_value_check_joint_purchase" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_6_retirement_value_check_joint_purchase") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_6_retired_under_soft_min_age?" => true, "jointpur" => 1 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_6", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_6", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_6", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end end - context "with person 5" do - let(:person_index) { 5 } - let(:page_id) { "person_5_retirement_value_check" } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) - end - - it "has the correct id" do - expect(page.id).to eq("person_5_retirement_value_check") + context "without joint purchase" do + context "with person 1" do + let(:person_index) { 1 } + let(:page_id) { "person_1_retirement_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_1_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_1_retired_under_soft_min_age?" => true, "jointpur" => 2 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_1", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "person_5_retired_under_soft_min_age?" => true }]) - end - - it "has correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", - "arguments" => [ - { - "key" => "retirement_age_for_person_5", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - - it "has correct informative_text" do - expect(page.informative_text).to eq({ - "translation" => "soft_validations.retirement.min.hint_text", - "arguments" => [ - { - "key" => "plural_gender_for_person_5", - "label" => false, - "i18n_template" => "gender", - }, - { - "key" => "retirement_age_for_person_5", - "label" => false, - "i18n_template" => "age", - }, - ], - }) - end - end - - context "with person 6" do - let(:person_index) { 6 } - let(:page_id) { "person_6_retirement_value_check" } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + context "with person 2" do + let(:person_index) { 2 } + let(:page_id) { "person_2_retirement_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_2_retired_under_soft_min_age?" => true, "jointpur" => 2 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_2", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has the correct id" do - expect(page.id).to eq("person_6_retirement_value_check") + context "with person 3" do + let(:person_index) { 2 } + let(:page_id) { "person_3_retirement_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_2_retired_under_soft_min_age?" => true, "jointpur" => 2 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_2", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "person_6_retired_under_soft_min_age?" => true }]) + context "with person 4" do + let(:person_index) { 3 } + let(:page_id) { "person_4_retirement_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_4_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_3_retired_under_soft_min_age?" => true, "jointpur" => 2 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_3", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", - "arguments" => [ - { - "key" => "retirement_age_for_person_6", - "label" => false, - "i18n_template" => "age", - }, - ], - }) + context "with person 5" do + let(:person_index) { 4 } + let(:page_id) { "person_5_retirement_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_5_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_4_retired_under_soft_min_age?" => true, "jointpur" => 2 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_4", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_4", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_4", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end - it "has correct informative_text" do - expect(page.informative_text).to eq({ - "translation" => "soft_validations.retirement.min.hint_text", - "arguments" => [ - { - "key" => "plural_gender_for_person_6", - "label" => false, - "i18n_template" => "gender", - }, - { - "key" => "retirement_age_for_person_6", - "label" => false, - "i18n_template" => "age", - }, - ], - }) + context "with person 6" do + let(:person_index) { 5 } + let(:page_id) { "person_6_retirement_value_check" } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("person_6_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([{ "person_5_retired_under_soft_min_age?" => true, "jointpur" => 2 }]) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_5", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_5", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_5", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end end end end diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 30d197593..64ca5469f 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -18,8 +18,10 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model privacy_notice buyer_1_age person_1_age_retirement_value_check + person_1_age_retirement_value_check_joint_purchase buyer_1_gender_identity person_1_gender_retirement_value_check + person_1_gender_retirement_value_check_joint_purchase buyer_1_ethnic_group buyer_1_ethnic_background_black buyer_1_ethnic_background_asian @@ -29,15 +31,19 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_1_nationality buyer_1_working_situation person_1_working_situation_retirement_value_check + person_1_working_situation_retirement_value_check_joint_purchase working_situation_buyer_1_income_value_check buyer_1_live_in_property buyer_2_relationship_to_buyer_1 buyer_2_age person_2_age_retirement_value_check + person_2_age_retirement_value_check_joint_purchase buyer_2_gender_identity person_2_gender_retirement_value_check + person_2_gender_retirement_value_check_joint_purchase buyer_2_working_situation person_2_working_situation_retirement_value_check + person_2_working_situation_retirement_value_check_joint_purchase buyer_2_live_in_property number_of_others_in_property person_1_known @@ -45,53 +51,65 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model person_1_relationship_to_buyer_1 person_1_relationship_to_buyer_1_joint_purchase person_1_age - person_1_age_joint_purchase person_3_age_retirement_value_check + person_1_age_joint_purchase + person_3_age_retirement_value_check_joint_purchase person_1_gender_identity - person_1_gender_identity_joint_purchase person_3_gender_retirement_value_check + person_1_gender_identity_joint_purchase + person_3_gender_retirement_value_check_joint_purchase person_1_working_situation - person_1_working_situation_joint_purchase person_3_working_situation_retirement_value_check + person_1_working_situation_joint_purchase + person_3_working_situation_retirement_value_check_joint_purchase person_2_known person_2_known_joint_purchase person_2_relationship_to_buyer_1 person_2_relationship_to_buyer_1_joint_purchase person_2_age - person_2_age_joint_purchase person_4_age_retirement_value_check + person_2_age_joint_purchase + person_4_age_retirement_value_check_joint_purchase person_2_gender_identity - person_2_gender_identity_joint_purchase person_4_gender_retirement_value_check + person_2_gender_identity_joint_purchase + person_4_gender_retirement_value_check_joint_purchase person_2_working_situation - person_2_working_situation_joint_purchase person_4_working_situation_retirement_value_check + person_2_working_situation_joint_purchase + person_4_working_situation_retirement_value_check_joint_purchase person_3_known person_3_known_joint_purchase person_3_relationship_to_buyer_1 person_3_relationship_to_buyer_1_joint_purchase person_3_age - person_3_age_joint_purchase person_5_age_retirement_value_check + person_3_age_joint_purchase + person_5_age_retirement_value_check_joint_purchase person_3_gender_identity - person_3_gender_identity_joint_purchase person_5_gender_retirement_value_check + person_3_gender_identity_joint_purchase + person_5_gender_retirement_value_check_joint_purchase person_3_working_situation - person_3_working_situation_joint_purchase person_5_working_situation_retirement_value_check + person_3_working_situation_joint_purchase + person_5_working_situation_retirement_value_check_joint_purchase person_4_known person_4_known_joint_purchase person_4_relationship_to_buyer_1 person_4_relationship_to_buyer_1_joint_purchase person_4_age - person_4_age_joint_purchase person_6_age_retirement_value_check + person_4_age_joint_purchase + person_6_age_retirement_value_check_joint_purchase person_4_gender_identity - person_4_gender_identity_joint_purchase person_6_gender_retirement_value_check + person_4_gender_identity_joint_purchase + person_6_gender_retirement_value_check_joint_purchase person_4_working_situation - person_4_working_situation_joint_purchase person_6_working_situation_retirement_value_check + person_4_working_situation_joint_purchase + person_6_working_situation_retirement_value_check_joint_purchase ], ) end diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 3bdb56c30..e2c68e16e 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -52,14 +52,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(167) + expect(form.pages.count).to eq(185) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(167) + expect(form.pages.count).to eq(185) expect(form.name).to eq("2021_2022_sales") end end