Browse Source

Add the new questions to the correct year

pull/1287/head
Kat 3 years ago
parent
commit
5d9a912289
  1. 14
      app/models/form/sales/subsections/household_characteristics.rb
  2. 218
      spec/models/form/sales/subsections/household_characteristics_spec.rb

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

@ -32,6 +32,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::RetirementValueCheck.new("age_2_buyer_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("age_2_buyer_retirement_value_check", 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("gender_2_buyer_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("gender_2_buyer_retirement_value_check", nil, self, person_index: 2),
ethnic_pages_for_buyer_2,
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_buyer_retirement_value_check", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_buyer_retirement_value_check", nil, self, person_index: 2),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
@ -68,6 +69,17 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::RetirementValueCheck.new("gender_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("gender_5_retirement_value_check", nil, self, person_index: 5),
Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5),
Form::Sales::Pages::RetirementValueCheck.new("working_situation_5_retirement_value_check", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("working_situation_5_retirement_value_check", nil, self, person_index: 5),
] ].flatten.compact
end
def ethnic_pages_for_buyer_2
if form.start_date.year >= 2023
[Form::Sales::Pages::Buyer2EthnicGroup.new(nil, nil, self),
Form::Sales::Pages::Buyer2EthnicBackgroundBlack.new(nil, nil, self),
Form::Sales::Pages::Buyer2EthnicBackgroundAsian.new(nil, nil, self),
Form::Sales::Pages::Buyer2EthnicBackgroundArab.new(nil, nil, self),
Form::Sales::Pages::Buyer2EthnicBackgroundMixed.new(nil, nil, self),
Form::Sales::Pages::Buyer2EthnicBackgroundWhite.new(nil, nil, self)]
end
end end
end end

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

@ -6,76 +6,164 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
let(:subsection_id) { nil } let(:subsection_id) { nil }
let(:subsection_definition) { nil } let(:subsection_definition) { nil }
let(:section) { instance_double(Form::Sales::Sections::Household) } let(:section) { instance_double(Form::Sales::Sections::Household) }
let(:form) { instance_double(Form) }
it "has correct section" do it "has correct section" do
expect(household_characteristics.section).to eq(section) expect(household_characteristics.section).to eq(section)
end end
it "has correct pages" do context "with 2022/23 form" do
expect(household_characteristics.pages.map(&:id)).to eq( before do
%w[ allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1))
buyer_interview allow(section).to receive(:form).and_return(form)
privacy_notice end
buyer_1_age
age_1_retirement_value_check it "has correct pages" do
age_1_old_persons_shared_ownership_value_check expect(household_characteristics.pages.map(&:id)).to eq(
buyer_1_gender_identity %w[
gender_1_retirement_value_check buyer_interview
buyer_1_ethnic_group privacy_notice
buyer_1_ethnic_background_black buyer_1_age
buyer_1_ethnic_background_asian age_1_retirement_value_check
buyer_1_ethnic_background_arab age_1_old_persons_shared_ownership_value_check
buyer_1_ethnic_background_mixed buyer_1_gender_identity
buyer_1_ethnic_background_white gender_1_retirement_value_check
buyer_1_nationality buyer_1_ethnic_group
buyer_1_working_situation buyer_1_ethnic_background_black
working_situation_1_retirement_value_check buyer_1_ethnic_background_asian
working_situation_buyer_1_income_value_check buyer_1_ethnic_background_arab
buyer_1_live_in_property buyer_1_ethnic_background_mixed
buyer_2_relationship_to_buyer_1 buyer_1_ethnic_background_white
buyer_2_age buyer_1_nationality
age_2_old_persons_shared_ownership_value_check buyer_1_working_situation
age_2_buyer_retirement_value_check working_situation_1_retirement_value_check
buyer_2_gender_identity working_situation_buyer_1_income_value_check
gender_2_buyer_retirement_value_check buyer_1_live_in_property
buyer_2_working_situation buyer_2_relationship_to_buyer_1
working_situation_2_buyer_retirement_value_check buyer_2_age
buyer_2_live_in_property age_2_old_persons_shared_ownership_value_check
number_of_others_in_property age_2_buyer_retirement_value_check
person_2_known buyer_2_gender_identity
person_2_relationship_to_buyer_1 gender_2_buyer_retirement_value_check
person_2_age buyer_2_working_situation
age_2_retirement_value_check working_situation_2_buyer_retirement_value_check
person_2_gender_identity buyer_2_live_in_property
gender_2_retirement_value_check number_of_others_in_property
person_2_working_situation person_2_known
working_situation_2_retirement_value_check person_2_relationship_to_buyer_1
person_3_known person_2_age
person_3_relationship_to_buyer_1 age_2_retirement_value_check
person_3_age person_2_gender_identity
age_3_retirement_value_check gender_2_retirement_value_check
person_3_gender_identity person_2_working_situation
gender_3_retirement_value_check working_situation_2_retirement_value_check
person_3_working_situation person_3_known
working_situation_3_retirement_value_check person_3_relationship_to_buyer_1
person_4_known person_3_age
person_4_relationship_to_buyer_1 age_3_retirement_value_check
person_4_age person_3_gender_identity
age_4_retirement_value_check gender_3_retirement_value_check
person_4_gender_identity person_3_working_situation
gender_4_retirement_value_check working_situation_3_retirement_value_check
person_4_working_situation person_4_known
working_situation_4_retirement_value_check person_4_relationship_to_buyer_1
person_5_known person_4_age
person_5_relationship_to_buyer_1 age_4_retirement_value_check
person_5_age person_4_gender_identity
age_5_retirement_value_check gender_4_retirement_value_check
person_5_gender_identity person_4_working_situation
gender_5_retirement_value_check working_situation_4_retirement_value_check
person_5_working_situation person_5_known
working_situation_5_retirement_value_check person_5_relationship_to_buyer_1
], person_5_age
) age_5_retirement_value_check
person_5_gender_identity
gender_5_retirement_value_check
person_5_working_situation
working_situation_5_retirement_value_check
],
)
end
end
context "with 2023/24 form" do
before do
allow(form).to receive(:start_date).and_return(Time.zone.local(2023, 4, 1))
allow(section).to receive(:form).and_return(form)
end
it "has correct pages" do
expect(household_characteristics.pages.map(&:id)).to eq(
%w[
buyer_interview
privacy_notice
buyer_1_age
age_1_retirement_value_check
age_1_old_persons_shared_ownership_value_check
buyer_1_gender_identity
gender_1_retirement_value_check
buyer_1_ethnic_group
buyer_1_ethnic_background_black
buyer_1_ethnic_background_asian
buyer_1_ethnic_background_arab
buyer_1_ethnic_background_mixed
buyer_1_ethnic_background_white
buyer_1_nationality
buyer_1_working_situation
working_situation_1_retirement_value_check
working_situation_buyer_1_income_value_check
buyer_1_live_in_property
buyer_2_relationship_to_buyer_1
buyer_2_age
age_2_old_persons_shared_ownership_value_check
age_2_buyer_retirement_value_check
buyer_2_gender_identity
gender_2_buyer_retirement_value_check
buyer_2_ethnic_group
buyer_2_ethnic_background_black
buyer_2_ethnic_background_asian
buyer_2_ethnic_background_arab
buyer_2_ethnic_background_mixed
buyer_2_ethnic_background_white
buyer_2_working_situation
working_situation_2_buyer_retirement_value_check
buyer_2_live_in_property
number_of_others_in_property
person_2_known
person_2_relationship_to_buyer_1
person_2_age
age_2_retirement_value_check
person_2_gender_identity
gender_2_retirement_value_check
person_2_working_situation
working_situation_2_retirement_value_check
person_3_known
person_3_relationship_to_buyer_1
person_3_age
age_3_retirement_value_check
person_3_gender_identity
gender_3_retirement_value_check
person_3_working_situation
working_situation_3_retirement_value_check
person_4_known
person_4_relationship_to_buyer_1
person_4_age
age_4_retirement_value_check
person_4_gender_identity
gender_4_retirement_value_check
person_4_working_situation
working_situation_4_retirement_value_check
person_5_known
person_5_relationship_to_buyer_1
person_5_age
age_5_retirement_value_check
person_5_gender_identity
gender_5_retirement_value_check
person_5_working_situation
working_situation_5_retirement_value_check
],
)
end
end end
it "has the correct id" do it "has the correct id" do

Loading…
Cancel
Save