diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 1b884ff0e..34085c52a 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -8,7 +8,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ - Form::Sales::Pages::BuyerInterview.new(nil, nil, self), + (Form::Sales::Pages::BuyerInterview.new(nil, nil, self) unless form.start_year_after_2024?), Form::Sales::Pages::PrivacyNotice.new(nil, nil, self), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("age_1_retirement_value_check", nil, self, person_index: 1), diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb index 26a47c700..aef107585 100644 --- a/app/models/form/sales/subsections/setup.rb +++ b/app/models/form/sales/subsections/setup.rb @@ -20,6 +20,7 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection Form::Sales::Pages::BuyerLive.new(nil, nil, self), Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self), - ] + (Form::Sales::Pages::BuyerInterview.new(nil, nil, self) if form.start_year_after_2024?), + ].flatten.compact 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 bcc30d741..00e96450f 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -8,6 +8,10 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model let(:section) { instance_double(Form::Sales::Sections::Household) } let(:form) { instance_double(Form) } + before do + allow(section).to receive(:form).and_return(form) + end + it "has correct section" do expect(household_characteristics.section).to eq(section) end @@ -15,7 +19,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model context "with 2022/23 form" do before do allow(form).to receive(:start_date).and_return(Time.zone.local(2022, 4, 1)) - allow(section).to receive(:form).and_return(form) + allow(form).to receive(:start_year_after_2024?).and_return(false) end it "has correct pages" do @@ -119,7 +123,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model 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) + allow(form).to receive(:start_year_after_2024?).and_return(false) end it "has correct pages" do @@ -227,6 +231,116 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model end end + context "with 2024/25 form" do + before do + allow(form).to receive(:start_date).and_return(Time.zone.local(2024, 4, 1)) + allow(form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has correct pages" do + expect(household_characteristics.pages.map(&:id)).to eq( + %w[ + 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_min_value_check + buyer_1_live_in_property + buyer_1_live_in_property_value_check + buyer_2_relationship_to_buyer_1 + buyer_2_relationship_student_not_child_value_check + buyer_2_age + age_2_old_persons_shared_ownership_value_check + age_2_buyer_retirement_value_check + buyer_2_age_student_not_child_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_nationality + buyer_2_working_situation + working_situation_2_retirement_value_check_joint_purchase + working_situation_buyer_2_income_min_value_check + buyer_2_working_situation_student_not_child_value_check + buyer_2_live_in_property + buyer_2_live_in_property_value_check + number_of_others_in_property + number_of_others_in_property_joint_purchase + person_2_known + person_2_relationship_to_buyer_1 + relationship_2_student_not_child_value_check + person_2_age + age_2_retirement_value_check + age_2_student_not_child_value_check + person_2_gender_identity + gender_2_retirement_value_check + person_2_working_situation + working_situation_2_retirement_value_check + working_situation_2_student_not_child_value_check + person_3_known + person_3_relationship_to_buyer_1 + relationship_3_student_not_child_value_check + person_3_age + age_3_retirement_value_check + age_3_student_not_child_value_check + person_3_gender_identity + gender_3_retirement_value_check + person_3_working_situation + working_situation_3_retirement_value_check + working_situation_3_student_not_child_value_check + person_4_known + person_4_relationship_to_buyer_1 + relationship_4_student_not_child_value_check + person_4_age + age_4_retirement_value_check + age_4_student_not_child_value_check + person_4_gender_identity + gender_4_retirement_value_check + person_4_working_situation + working_situation_4_retirement_value_check + working_situation_4_student_not_child_value_check + person_5_known + person_5_relationship_to_buyer_1 + relationship_5_student_not_child_value_check + person_5_age + age_5_retirement_value_check + age_5_student_not_child_value_check + person_5_gender_identity + gender_5_retirement_value_check + person_5_working_situation + working_situation_5_retirement_value_check + working_situation_5_student_not_child_value_check + person_6_known + person_6_relationship_to_buyer_1 + relationship_6_student_not_child_value_check + person_6_age + age_6_retirement_value_check + age_6_student_not_child_value_check + person_6_gender_identity + gender_6_retirement_value_check + person_6_working_situation + working_situation_6_retirement_value_check + working_situation_6_student_not_child_value_check + ], + ) + end + end + it "has the correct id" do expect(household_characteristics.id).to eq("household_characteristics") end diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index cdc3aff8d..2ddb64e19 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -12,26 +12,6 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do expect(setup.section).to eq(section) end - it "has correct pages" do - expect(setup.pages.map(&:id)).to eq( - %w[ - owning_organisation - managing_organisation - created_by - completion_date - purchaser_code - ownership_scheme - shared_ownership_type - discounted_ownership_type - outright_ownership_type - buyer_company - buyer_live - joint_purchase - number_joint_buyers - ], - ) - end - it "has the correct id" do expect(setup.id).to eq("setup") end @@ -39,4 +19,57 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do it "has the correct label" do expect(setup.label).to eq("Set up this sales log") end + + context "when start year is before 2024" do + before do + allow(section.form).to receive(:start_year_after_2024?).and_return(false) + end + + it "has correct pages" do + expect(setup.pages.map(&:id)).to eq( + %w[ + owning_organisation + managing_organisation + created_by + completion_date + purchaser_code + ownership_scheme + shared_ownership_type + discounted_ownership_type + outright_ownership_type + buyer_company + buyer_live + joint_purchase + number_joint_buyers + ], + ) + end + end + + context "when start year is >= 2024" do + before do + allow(section.form).to receive(:start_year_after_2024?).and_return(true) + end + + it "has correct pages" do + expect(setup.pages.map(&:id)).to eq( + %w[ + owning_organisation + managing_organisation + created_by + completion_date + purchaser_code + ownership_scheme + shared_ownership_type + discounted_ownership_type + outright_ownership_type + buyer_company + buyer_live + joint_purchase + number_joint_buyers + buyer_interview + ], + ) + end + end end diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 0f4fc5898..fa5ad2ee7 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -287,7 +287,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_18 field_4 field_5 field_6 field_8]) + expect(errors).to eql(%i[field_1 field_17 field_18 field_4 field_5 field_6 field_8]) end end @@ -303,7 +303,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_15 field_18 field_4 field_5 field_6 field_9]) + expect(errors).to eql(%i[field_1 field_15 field_17 field_18 field_4 field_5 field_6 field_9]) end end @@ -321,7 +321,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_16 field_18 field_4 field_5 field_6]) + expect(errors).to eql(%i[field_1 field_16 field_17 field_18 field_4 field_5 field_6]) end end @@ -338,11 +338,11 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_10 field_15 field_18 field_4 field_5 field_6]) + expect(errors).to eql(%i[field_1 field_10 field_15 field_17 field_18 field_4 field_5 field_6]) end end - context "when setup section not complete it's discounted ownership joint purchase" do + context "when setup section not complete and it's discounted ownership joint purchase" do let(:attributes) do { bulk_upload:, @@ -356,7 +356,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_18 field_4 field_5 field_6 field_8]) + expect(errors).to eql(%i[field_1 field_17 field_18 field_4 field_5 field_6 field_8]) end end @@ -372,7 +372,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_11 field_13 field_14 field_18 field_4 field_5 field_6]) + expect(errors).to eql(%i[field_1 field_11 field_13 field_14 field_17 field_18 field_4 field_5 field_6]) end end @@ -390,7 +390,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "has errors on correct setup fields" do errors = parser.errors.select { |e| e.options[:category] == :setup }.map(&:attribute).sort - expect(errors).to eql(%i[field_1 field_12 field_14 field_15 field_18 field_4 field_5 field_6]) + expect(errors).to eql(%i[field_1 field_12 field_14 field_15 field_17 field_18 field_4 field_5 field_6]) end end