diff --git a/app/models/form/sales/pages/about_price_shared_ownership.rb b/app/models/form/sales/pages/about_price_shared_ownership.rb deleted file mode 100644 index 1f65a7d19..000000000 --- a/app/models/form/sales/pages/about_price_shared_ownership.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Form::Sales::Pages::AboutPriceSharedOwnership < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "about_price_shared_ownership" - @header = "About the price of the property" - end - - def questions - @questions ||= [ - Form::Sales::Questions::Value.new(nil, nil, self), - Form::Sales::Questions::Equity.new(nil, nil, self), - ] - end -end diff --git a/app/models/form/sales/pages/about_deposit_without_discount.rb b/app/models/form/sales/pages/deposit.rb similarity index 70% rename from app/models/form/sales/pages/about_deposit_without_discount.rb rename to app/models/form/sales/pages/deposit.rb index 5747c3ed4..40d8f99c6 100644 --- a/app/models/form/sales/pages/about_deposit_without_discount.rb +++ b/app/models/form/sales/pages/deposit.rb @@ -1,7 +1,6 @@ -class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page +class Form::Sales::Pages::Deposit < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:, optional:) super(id, hsh, subsection) - @header = "About the deposit" @ownershipsch = ownershipsch @optional = optional end @@ -16,11 +15,13 @@ class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page if form.start_year_after_2024? [{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => @optional }, { "ownershipsch" => 2 }, - { "ownershipsch" => 3, "mortgageused" => 1 }] + { "ownershipsch" => 3, "mortgageused" => 1 }, + { "social_homebuy?" => true, "stairowned_100?" => @optional }] else [{ "social_homebuy?" => false, "ownershipsch" => 1 }, { "ownershipsch" => 2 }, - { "ownershipsch" => 3, "mortgageused" => 1 }] + { "ownershipsch" => 3, "mortgageused" => 1 }, + { "social_homebuy?" => true }] end end end diff --git a/app/models/form/sales/pages/about_deposit_with_discount.rb b/app/models/form/sales/pages/discount.rb similarity index 67% rename from app/models/form/sales/pages/about_deposit_with_discount.rb rename to app/models/form/sales/pages/discount.rb index 4f1eed451..a69f4a52b 100644 --- a/app/models/form/sales/pages/about_deposit_with_discount.rb +++ b/app/models/form/sales/pages/discount.rb @@ -1,13 +1,11 @@ -class Form::Sales::Pages::AboutDepositWithDiscount < ::Form::Page +class Form::Sales::Pages::Discount < ::Form::Page def initialize(id, hsh, subsection, optional:) super(id, hsh, subsection) - @header = "About the deposit" @optional = optional end def questions @questions ||= [ - Form::Sales::Questions::DepositAmount.new(nil, nil, self, ownershipsch: 1, optional: @optional), Form::Sales::Questions::DepositDiscount.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/equity.rb b/app/models/form/sales/pages/equity.rb new file mode 100644 index 000000000..46eec40a3 --- /dev/null +++ b/app/models/form/sales/pages/equity.rb @@ -0,0 +1,12 @@ +class Form::Sales::Pages::Equity < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "equity" + end + + def questions + @questions ||= [ + Form::Sales::Questions::Equity.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/value_shared_ownership.rb b/app/models/form/sales/pages/value_shared_ownership.rb new file mode 100644 index 000000000..200563053 --- /dev/null +++ b/app/models/form/sales/pages/value_shared_ownership.rb @@ -0,0 +1,12 @@ +class Form::Sales::Pages::ValueSharedOwnership < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "value_shared_ownership" + end + + def questions + @questions ||= [ + Form::Sales::Questions::Value.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index dd115786f..e8af859cf 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -32,7 +32,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_discounted_ownership", nil, self, ownershipsch: 2), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check", nil, self), - Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self, ownershipsch: 2, optional: false), + Form::Sales::Pages::Deposit.new("deposit_discounted_ownership", nil, self, ownershipsch: 2, optional: false), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_deposit_value_check", nil, self), Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self, joint_purchase: false), diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 15d95f4b7..6b29313a1 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -18,7 +18,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection (Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_after_2024?), Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self, ownershipsch: 3), - Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self, ownershipsch: 3, optional: false), + Form::Sales::Pages::Deposit.new("deposit_outright_sale", nil, self, ownershipsch: 3, optional: false), Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self, joint_purchase: false), leasehold_charge_pages, diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 01697baff..0d9f363a0 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -26,8 +26,9 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self), Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self), Form::Sales::Pages::PreviousTenure.new(nil, nil, self), - Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self), + Form::Sales::Pages::ValueSharedOwnership.new(nil, nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), + Form::Sales::Pages::Equity.new(nil, nil, self), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self), @@ -38,10 +39,12 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self, ownershipsch: 1), - Form::Sales::Pages::AboutDepositWithDiscount.new("about_deposit_with_discount", nil, self, optional: false), - (Form::Sales::Pages::AboutDepositWithDiscount.new("about_deposit_with_discount_optional", nil, self, optional: true) if form.start_year_after_2024?), - Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self, ownershipsch: 1, optional: false), - (Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_after_2024?), + Form::Sales::Pages::Deposit.new("deposit", nil, self, optional: false, ownershipsch: 1), + Form::Sales::Pages::Discount.new("discount", nil, self, optional: false), + (Form::Sales::Pages::Deposit.new("deposit_optional", nil, self, optional: true, ownershipsch: 1) if form.start_year_after_2024?), + (Form::Sales::Pages::Discount.new("discount_optional", nil, self, optional: true) if form.start_year_after_2024?), + Form::Sales::Pages::Deposit.new("deposit_shared_ownership", nil, self, ownershipsch: 1, optional: false), + (Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_after_2024?), Form::Sales::Pages::DepositValueCheck.new("deposit_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self), diff --git a/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb b/spec/models/form/sales/pages/deposit_spec.rb similarity index 79% rename from spec/models/form/sales/pages/about_deposit_without_discount_spec.rb rename to spec/models/form/sales/pages/deposit_spec.rb index 003313353..1f6a1d867 100644 --- a/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb +++ b/spec/models/form/sales/pages/deposit_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do +RSpec.describe Form::Sales::Pages::Deposit, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection, ownershipsch: 1, optional: false) } let(:page_id) { nil } @@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do end it "has the correct header" do - expect(page.header).to eq("About the deposit") + expect(page.header).to be_nil end it "has the correct description" do @@ -35,7 +35,8 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do expect(page.depends_on).to eq( [{ "social_homebuy?" => false, "ownershipsch" => 1 }, { "ownershipsch" => 2 }, - { "ownershipsch" => 3, "mortgageused" => 1 }], + { "ownershipsch" => 3, "mortgageused" => 1 }, + { "social_homebuy?" => true }], ) end @@ -46,7 +47,8 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do expect(page.depends_on).to eq( [{ "social_homebuy?" => false, "ownershipsch" => 1 }, { "ownershipsch" => 2 }, - { "ownershipsch" => 3, "mortgageused" => 1 }], + { "ownershipsch" => 3, "mortgageused" => 1 }, + { "social_homebuy?" => true }], ) end end @@ -60,7 +62,8 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do expect(page.depends_on).to eq( [{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => false }, { "ownershipsch" => 2 }, - { "ownershipsch" => 3, "mortgageused" => 1 }], + { "ownershipsch" => 3, "mortgageused" => 1 }, + { "social_homebuy?" => true, "stairowned_100?" => false }], ) end @@ -71,7 +74,8 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do expect(page.depends_on).to eq( [{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => true }, { "ownershipsch" => 2 }, - { "ownershipsch" => 3, "mortgageused" => 1 }], + { "ownershipsch" => 3, "mortgageused" => 1 }, + { "social_homebuy?" => true, "stairowned_100?" => true }], ) end end diff --git a/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb b/spec/models/form/sales/pages/discount_spec.rb similarity index 85% rename from spec/models/form/sales/pages/about_deposit_with_discount_spec.rb rename to spec/models/form/sales/pages/discount_spec.rb index fabfb7836..980c09852 100644 --- a/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb +++ b/spec/models/form/sales/pages/discount_spec.rb @@ -1,9 +1,9 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do +RSpec.describe Form::Sales::Pages::Discount, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection, optional: false) } - let(:page_id) { "about_deposit_with_discount" } + let(:page_id) { "discount" } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection) } @@ -16,15 +16,15 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[deposit cashdis]) + expect(page.questions.map(&:id)).to eq(%w[cashdis]) end it "has the correct id" do - expect(page.id).to eq("about_deposit_with_discount") + expect(page.id).to eq("discount") end it "has the correct header" do - expect(page.header).to eq("About the deposit") + expect(page.header).to be_nil end it "has the correct description" do diff --git a/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb b/spec/models/form/sales/pages/equity_spec.rb similarity index 71% rename from spec/models/form/sales/pages/about_price_shared_ownership_spec.rb rename to spec/models/form/sales/pages/equity_spec.rb index 7074a3ca9..d45b6cecb 100644 --- a/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb +++ b/spec/models/form/sales/pages/equity_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutPriceSharedOwnership, type: :model do +RSpec.describe Form::Sales::Pages::Equity, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -12,15 +12,15 @@ RSpec.describe Form::Sales::Pages::AboutPriceSharedOwnership, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[value equity]) + expect(page.questions.map(&:id)).to eq(%w[equity]) end it "has the correct id" do - expect(page.id).to eq("about_price_shared_ownership") + expect(page.id).to eq("equity") end it "has the correct header" do - expect(page.header).to eq("About the price of the property") + expect(page.header).to be_nil end it "has the correct description" do diff --git a/spec/models/form/sales/pages/value_shared_ownership_spec.rb b/spec/models/form/sales/pages/value_shared_ownership_spec.rb new file mode 100644 index 000000000..223c4b329 --- /dev/null +++ b/spec/models/form/sales/pages/value_shared_ownership_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::ValueSharedOwnership, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { nil } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[value]) + end + + it "has the correct id" do + expect(page.id).to eq("value_shared_ownership") + 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 be_nil + end +end diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb index 5f20cbb91..9bb428569 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model mortgage_length_discounted_ownership extra_borrowing_discounted_ownership extra_borrowing_value_check - about_deposit_discounted_ownership + deposit_discounted_ownership extra_borrowing_deposit_value_check discounted_ownership_deposit_joint_purchase_value_check discounted_ownership_deposit_value_check diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index efb2aaad6..0d28330f2 100644 --- a/spec/models/form/sales/subsections/outright_sale_spec.rb +++ b/spec/models/form/sales/subsections/outright_sale_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do mortgage_lender_other_outright_sale mortgage_length_outright_sale extra_borrowing_outright_sale - about_deposit_outright_sale + deposit_outright_sale outright_sale_deposit_joint_purchase_value_check outright_sale_deposit_value_check monthly_charges_outright_sale_value_check @@ -67,7 +67,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do mortgage_lender_other_outright_sale mortgage_length_outright_sale extra_borrowing_outright_sale - about_deposit_outright_sale + deposit_outright_sale outright_sale_deposit_joint_purchase_value_check outright_sale_deposit_value_check leasehold_charges_outright_sale @@ -94,7 +94,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do outright_sale_mortgage_amount_mortgage_value_check mortgage_length_outright_sale extra_borrowing_outright_sale - about_deposit_outright_sale + deposit_outright_sale outright_sale_deposit_joint_purchase_value_check outright_sale_deposit_value_check leasehold_charges_outright_sale diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb index 59e7bfbfb..685e92877 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -36,8 +36,9 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do previous_bedrooms previous_property_type shared_ownership_previous_tenure - about_price_shared_ownership + value_shared_ownership about_price_shared_ownership_value_check + equity shared_ownership_equity_value_check mortgage_used_shared_ownership mortgage_used_mortgage_value_check @@ -48,8 +49,9 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do mortgage_lender_other_shared_ownership mortgage_length_shared_ownership extra_borrowing_shared_ownership - about_deposit_with_discount - about_deposit_shared_ownership + deposit + discount + deposit_shared_ownership deposit_joint_purchase_value_check deposit_value_check shared_ownership_deposit_value_check