diff --git a/app/models/form/sales/pages/buyer2_nationality.rb b/app/models/form/sales/pages/buyer2_nationality.rb new file mode 100644 index 000000000..271cd394d --- /dev/null +++ b/app/models/form/sales/pages/buyer2_nationality.rb @@ -0,0 +1,11 @@ +class Form::Sales::Pages::Buyer2Nationality < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_2_nationality" + @depends_on = [{ "joint_purchase?" => true }] + end + + def questions + @questions ||= [Form::Sales::Questions::NationalityBuyer2.new(nil, nil, self)] + end +end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 0277acffb..f389c06f4 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -32,7 +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::GenderIdentity2.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("gender_2_buyer_retirement_value_check", nil, self, person_index: 2), - ethnic_pages_for_buyer_2, + pages_for_buyer_2, Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::Buyer2IncomeValueCheck.new("working_situation_buyer_2_income_value_check", nil, self), @@ -82,14 +82,17 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection ].flatten.compact end - def ethnic_pages_for_buyer_2 + def 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)] + [ + 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), + Form::Sales::Pages::Buyer2Nationality.new(nil, nil, self), + ] end end diff --git a/spec/models/form/sales/pages/buyer2_nationality_spec.rb b/spec/models/form/sales/pages/buyer2_nationality_spec.rb new file mode 100644 index 000000000..92c891f88 --- /dev/null +++ b/spec/models/form/sales/pages/buyer2_nationality_spec.rb @@ -0,0 +1,31 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer2Nationality, type: :model do + subject(:page) { described_class.new(nil, nil, subsection) } + + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to be subsection + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq %w[nationalbuy2] + end + + it "has the correct id" do + expect(page.id).to eq "buyer_2_nationality" + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq [{ "joint_purchase?" => true }] + end +end