Browse Source

Display the retirement value check in correct places depending on the joinpur value

pull/1191/head
Kat 3 years ago
parent
commit
e70068a758
  1. 5
      app/models/form/sales/pages/retirement_value_check.rb
  2. 42
      app/models/form/sales/subsections/household_characteristics.rb
  3. 328
      spec/models/form/sales/pages/retirement_value_check_spec.rb
  4. 42
      spec/models/form/sales/subsections/household_characteristics_spec.rb
  5. 4
      spec/models/form_handler_spec.rb

5
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:) def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection) super
@depends_on = [ @depends_on = [
{ {
"person_#{person_index}_retired_under_soft_min_age?" => true, "person_#{person_index}_retired_under_soft_min_age?" => true,
"jointpur" => joint_purchase? ? 1 : 2,
}, },
] ]
@person_index = person_index @person_index = person_index

42
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::PrivacyNotice.new(nil, nil, self),
Form::Sales::Pages::Age1.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", 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::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", 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::Buyer1EthnicGroup.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self), Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self),
Form::Sales::Pages::Buyer1EthnicBackgroundAsian.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::Nationality1.new(nil, nil, self),
Form::Sales::Pages::Buyer1WorkingSituation.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", 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::Buyer1IncomeValueCheck.new("working_situation_buyer_1_income_value_check", nil, self),
Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self),
Form::Sales::Pages::Age2.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", 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::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", 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::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", 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::Buyer2LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::NumberOfOthersInProperty.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), 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", 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::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::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::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::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::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::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::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", nil, self, person_index: 3),
Form::Sales::Pages::PersonKnown.new("person_2_known_joint_purchase", nil, self, person_index: 4), 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", 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::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::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::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::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::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::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::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", nil, self, person_index: 4),
Form::Sales::Pages::PersonKnown.new("person_3_known_joint_purchase", nil, self, person_index: 5), 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", 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::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::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::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::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::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::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::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", nil, self, person_index: 5),
Form::Sales::Pages::PersonKnown.new("person_4_known_joint_purchase", nil, self, person_index: 6), 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", 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::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::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::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::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::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::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::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
end end

328
spec/models/form/sales/pages/retirement_value_check_spec.rb

@ -21,20 +21,21 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
expect(page.description).to be_nil expect(page.description).to be_nil
end end
context "with joint purchase" do
context "with person 1" do context "with person 1" do
let(:person_index) { 1 } let(:person_index) { 1 }
let(:page_id) { "person_1_retirement_value_check" } let(:page_id) { "person_1_retirement_value_check_joint_purchase" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) expect(page.questions.map(&:id)).to eq(%w[retirement_value_check])
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("person_1_retirement_value_check") expect(page.id).to eq("person_1_retirement_value_check_joint_purchase")
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_1_retired_under_soft_min_age?" => true }]) expect(page.depends_on).to eq([{ "person_1_retired_under_soft_min_age?" => true, "jointpur" => 1 }])
end end
it "has correct title_text" do it "has correct title_text" do
@ -71,18 +72,18 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
context "with person 2" do context "with person 2" do
let(:person_index) { 2 } let(:person_index) { 2 }
let(:page_id) { "person_2_retirement_value_check" } let(:page_id) { "person_2_retirement_value_check_joint_purchase" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) expect(page.questions.map(&:id)).to eq(%w[retirement_value_check])
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("person_2_retirement_value_check") expect(page.id).to eq("person_2_retirement_value_check_joint_purchase")
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_2_retired_under_soft_min_age?" => true }]) expect(page.depends_on).to eq([{ "person_2_retired_under_soft_min_age?" => true, "jointpur" => 1 }])
end end
it "has correct title_text" do it "has correct title_text" do
@ -119,18 +120,18 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
context "with person 3" do context "with person 3" do
let(:person_index) { 3 } let(:person_index) { 3 }
let(:page_id) { "person_3_retirement_value_check" } let(:page_id) { "person_3_retirement_value_check_joint_purchase" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) expect(page.questions.map(&:id)).to eq(%w[retirement_value_check])
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("person_3_retirement_value_check") expect(page.id).to eq("person_3_retirement_value_check_joint_purchase")
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_3_retired_under_soft_min_age?" => true }]) expect(page.depends_on).to eq([{ "person_3_retired_under_soft_min_age?" => true, "jointpur" => 1 }])
end end
it "has correct title_text" do it "has correct title_text" do
@ -167,18 +168,18 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
context "with person 4" do context "with person 4" do
let(:person_index) { 4 } let(:person_index) { 4 }
let(:page_id) { "person_4_retirement_value_check" } let(:page_id) { "person_4_retirement_value_check_joint_purchase" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) expect(page.questions.map(&:id)).to eq(%w[retirement_value_check])
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("person_4_retirement_value_check") expect(page.id).to eq("person_4_retirement_value_check_joint_purchase")
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_4_retired_under_soft_min_age?" => true }]) expect(page.depends_on).to eq([{ "person_4_retired_under_soft_min_age?" => true, "jointpur" => 1 }])
end end
it "has correct title_text" do it "has correct title_text" do
@ -215,18 +216,18 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
context "with person 5" do context "with person 5" do
let(:person_index) { 5 } let(:person_index) { 5 }
let(:page_id) { "person_5_retirement_value_check" } let(:page_id) { "person_5_retirement_value_check_joint_purchase" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) expect(page.questions.map(&:id)).to eq(%w[retirement_value_check])
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("person_5_retirement_value_check") expect(page.id).to eq("person_5_retirement_value_check_joint_purchase")
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_5_retired_under_soft_min_age?" => true }]) expect(page.depends_on).to eq([{ "person_5_retired_under_soft_min_age?" => true, "jointpur" => 1 }])
end end
it "has correct title_text" do it "has correct title_text" do
@ -263,18 +264,18 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
context "with person 6" do context "with person 6" do
let(:person_index) { 6 } let(:person_index) { 6 }
let(:page_id) { "person_6_retirement_value_check" } let(:page_id) { "person_6_retirement_value_check_joint_purchase" }
it "has correct questions" do it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) expect(page.questions.map(&:id)).to eq(%w[retirement_value_check])
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("person_6_retirement_value_check") expect(page.id).to eq("person_6_retirement_value_check_joint_purchase")
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ "person_6_retired_under_soft_min_age?" => true }]) expect(page.depends_on).to eq([{ "person_6_retired_under_soft_min_age?" => true, "jointpur" => 1 }])
end end
it "has correct title_text" do it "has correct title_text" do
@ -308,4 +309,295 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do
}) })
end end
end end
end
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
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
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
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
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
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 end

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

@ -18,8 +18,10 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
privacy_notice privacy_notice
buyer_1_age buyer_1_age
person_1_age_retirement_value_check person_1_age_retirement_value_check
person_1_age_retirement_value_check_joint_purchase
buyer_1_gender_identity buyer_1_gender_identity
person_1_gender_retirement_value_check person_1_gender_retirement_value_check
person_1_gender_retirement_value_check_joint_purchase
buyer_1_ethnic_group buyer_1_ethnic_group
buyer_1_ethnic_background_black buyer_1_ethnic_background_black
buyer_1_ethnic_background_asian buyer_1_ethnic_background_asian
@ -29,15 +31,19 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_1_nationality buyer_1_nationality
buyer_1_working_situation buyer_1_working_situation
person_1_working_situation_retirement_value_check person_1_working_situation_retirement_value_check
person_1_working_situation_retirement_value_check_joint_purchase
working_situation_buyer_1_income_value_check working_situation_buyer_1_income_value_check
buyer_1_live_in_property buyer_1_live_in_property
buyer_2_relationship_to_buyer_1 buyer_2_relationship_to_buyer_1
buyer_2_age buyer_2_age
person_2_age_retirement_value_check person_2_age_retirement_value_check
person_2_age_retirement_value_check_joint_purchase
buyer_2_gender_identity buyer_2_gender_identity
person_2_gender_retirement_value_check person_2_gender_retirement_value_check
person_2_gender_retirement_value_check_joint_purchase
buyer_2_working_situation buyer_2_working_situation
person_2_working_situation_retirement_value_check person_2_working_situation_retirement_value_check
person_2_working_situation_retirement_value_check_joint_purchase
buyer_2_live_in_property buyer_2_live_in_property
number_of_others_in_property number_of_others_in_property
person_1_known 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
person_1_relationship_to_buyer_1_joint_purchase person_1_relationship_to_buyer_1_joint_purchase
person_1_age person_1_age
person_1_age_joint_purchase
person_3_age_retirement_value_check 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
person_1_gender_identity_joint_purchase
person_3_gender_retirement_value_check 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
person_1_working_situation_joint_purchase
person_3_working_situation_retirement_value_check 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
person_2_known_joint_purchase person_2_known_joint_purchase
person_2_relationship_to_buyer_1 person_2_relationship_to_buyer_1
person_2_relationship_to_buyer_1_joint_purchase person_2_relationship_to_buyer_1_joint_purchase
person_2_age person_2_age
person_2_age_joint_purchase
person_4_age_retirement_value_check 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
person_2_gender_identity_joint_purchase
person_4_gender_retirement_value_check 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
person_2_working_situation_joint_purchase
person_4_working_situation_retirement_value_check 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
person_3_known_joint_purchase person_3_known_joint_purchase
person_3_relationship_to_buyer_1 person_3_relationship_to_buyer_1
person_3_relationship_to_buyer_1_joint_purchase person_3_relationship_to_buyer_1_joint_purchase
person_3_age person_3_age
person_3_age_joint_purchase
person_5_age_retirement_value_check 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
person_3_gender_identity_joint_purchase
person_5_gender_retirement_value_check 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
person_3_working_situation_joint_purchase
person_5_working_situation_retirement_value_check 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
person_4_known_joint_purchase person_4_known_joint_purchase
person_4_relationship_to_buyer_1 person_4_relationship_to_buyer_1
person_4_relationship_to_buyer_1_joint_purchase person_4_relationship_to_buyer_1_joint_purchase
person_4_age person_4_age
person_4_age_joint_purchase
person_6_age_retirement_value_check 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
person_4_gender_identity_joint_purchase
person_6_gender_retirement_value_check 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
person_4_working_situation_joint_purchase
person_6_working_situation_retirement_value_check person_6_working_situation_retirement_value_check
person_4_working_situation_joint_purchase
person_6_working_situation_retirement_value_check_joint_purchase
], ],
) )
end end

4
spec/models/form_handler_spec.rb

@ -52,14 +52,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do it "is able to load a current sales form" do
form = form_handler.get_form("current_sales") form = form_handler.get_form("current_sales")
expect(form).to be_a(Form) 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") expect(form.name).to eq("2022_2023_sales")
end end
it "is able to load a previous sales form" do it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales") form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form) 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") expect(form.name).to eq("2021_2022_sales")
end end
end end

Loading…
Cancel
Save