Browse Source

Split questions

pull/2541/head
Kat 2 years ago
parent
commit
8de8b3047f
  1. 14
      app/models/form/sales/pages/about_price_shared_ownership.rb
  2. 9
      app/models/form/sales/pages/deposit.rb
  3. 4
      app/models/form/sales/pages/discount.rb
  4. 12
      app/models/form/sales/pages/equity.rb
  5. 12
      app/models/form/sales/pages/value_shared_ownership.rb
  6. 2
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  7. 2
      app/models/form/sales/subsections/outright_sale.rb
  8. 13
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  9. 16
      spec/models/form/sales/pages/deposit_spec.rb
  10. 10
      spec/models/form/sales/pages/discount_spec.rb
  11. 8
      spec/models/form/sales/pages/equity_spec.rb
  12. 33
      spec/models/form/sales/pages/value_shared_ownership_spec.rb
  13. 2
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
  14. 6
      spec/models/form/sales/subsections/outright_sale_spec.rb
  15. 8
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

14
app/models/form/sales/pages/about_price_shared_ownership.rb

@ -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

9
app/models/form/sales/pages/about_deposit_without_discount.rb → 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

4
app/models/form/sales/pages/about_deposit_with_discount.rb → 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

12
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

12
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

2
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),

2
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,

13
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),

16
spec/models/form/sales/pages/about_deposit_without_discount_spec.rb → 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

10
spec/models/form/sales/pages/about_deposit_with_discount_spec.rb → 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

8
spec/models/form/sales/pages/about_price_shared_ownership_spec.rb → 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

33
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

2
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

6
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

8
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

Loading…
Cancel
Save