diff --git a/app/models/form/sales/pages/about_price.rb b/app/models/form/sales/pages/about_price.rb deleted file mode 100644 index f5641791d..000000000 --- a/app/models/form/sales/pages/about_price.rb +++ /dev/null @@ -1,18 +0,0 @@ -class Form::Sales::Pages::AboutPrice < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "about_price" - @header = "About the price of the property" - @description = "" - @subsection = subsection - @depends_on = [{ - "soctenant" => 2, - }] - end - - def questions - @questions ||= [ - Form::Sales::Questions::Value.new(nil, nil, self), - ] - end -end diff --git a/app/models/form/sales/pages/about_price_social_housing.rb b/app/models/form/sales/pages/about_price_shared_ownership.rb similarity index 67% rename from app/models/form/sales/pages/about_price_social_housing.rb rename to app/models/form/sales/pages/about_price_shared_ownership.rb index bf8045f3d..b3f34c121 100644 --- a/app/models/form/sales/pages/about_price_social_housing.rb +++ b/app/models/form/sales/pages/about_price_shared_ownership.rb @@ -1,13 +1,10 @@ -class Form::Sales::Pages::AboutPriceSocialHousing < ::Form::Page +class Form::Sales::Pages::AboutPriceSharedOwnership < ::Form::Page def initialize(id, hsh, subsection) super - @id = "about_price_social_housing" + @id = "about_price_shared_ownership" @header = "About the price of the property" @description = "" @subsection = subsection - @depends_on = [{ - "soctenant" => 1, - }] end def questions diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb new file mode 100644 index 000000000..5eeb84138 --- /dev/null +++ b/app/models/form/sales/pages/purchase_price.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::PurchasePrice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "purchase_price" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::PurchasePrice.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb new file mode 100644 index 000000000..da714d9df --- /dev/null +++ b/app/models/form/sales/questions/purchase_price.rb @@ -0,0 +1,14 @@ +class Form::Sales::Questions::PurchasePrice < ::Form::Question + def initialize(id, hsh, page) + super + @id = "value" + @check_answer_label = "Purchase price" + @header = "What is the full purchase price?" + @type = "numeric" + @page = page + @min = 0 + @width = 5 + @prefix = "£" + @hint_text = "" + end +end diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 4b95d04c2..4b72720f0 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -9,6 +9,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection def pages @pages ||= [ + Form::Sales::Pages::PurchasePrice.new(nil, nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), Form::Sales::Pages::AboutDeposit.new("about_deposit_outright_sale", nil, self), ] diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index 750d9de88..49d378a73 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -16,8 +16,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::LaNominations.new(nil, nil, self), Form::Sales::Pages::BuyerPrevious.new(nil, nil, self), Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self), - Form::Sales::Pages::AboutPrice.new(nil, nil, self), - Form::Sales::Pages::AboutPriceSocialHousing.new(nil, nil, self), + Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self), Form::Sales::Pages::AboutDeposit.new("about_deposit_shared_ownership", nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self), diff --git a/spec/models/form/sales/pages/about_price_social_housing_spec.rb b/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb similarity index 76% rename from spec/models/form/sales/pages/about_price_social_housing_spec.rb rename to spec/models/form/sales/pages/about_price_shared_ownership_spec.rb index acdcd7dd3..c4e8d6ccc 100644 --- a/spec/models/form/sales/pages/about_price_social_housing_spec.rb +++ b/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutPriceSocialHousing, type: :model do +RSpec.describe Form::Sales::Pages::AboutPriceSharedOwnership, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceSocialHousing, type: :model do end it "has the correct id" do - expect(page.id).to eq("about_price_social_housing") + expect(page.id).to eq("about_price_shared_ownership") end it "has the correct header" do @@ -28,8 +28,6 @@ RSpec.describe Form::Sales::Pages::AboutPriceSocialHousing, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ - "soctenant" => 1, - }]) + expect(page.depends_on).to be_nil end end diff --git a/spec/models/form/sales/pages/about_price_spec.rb b/spec/models/form/sales/pages/purchase_price_spec.rb similarity index 71% rename from spec/models/form/sales/pages/about_price_spec.rb rename to spec/models/form/sales/pages/purchase_price_spec.rb index d6c45cd4b..f6cdef219 100644 --- a/spec/models/form/sales/pages/about_price_spec.rb +++ b/spec/models/form/sales/pages/purchase_price_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::AboutPrice, type: :model do +RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -16,11 +16,11 @@ RSpec.describe Form::Sales::Pages::AboutPrice, type: :model do end it "has the correct id" do - expect(page.id).to eq("about_price") + expect(page.id).to eq("purchase_price") end it "has the correct header" do - expect(page.header).to eq("About the price of the property") + expect(page.header).to eq("") end it "has the correct description" do @@ -28,8 +28,6 @@ RSpec.describe Form::Sales::Pages::AboutPrice, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ - "soctenant" => 2, - }]) + expect(page.depends_on).to be_nil end end diff --git a/spec/models/form/sales/questions/purchase_price_spec.rb b/spec/models/form/sales/questions/purchase_price_spec.rb new file mode 100644 index 000000000..1ee30b9a5 --- /dev/null +++ b/spec/models/form/sales/questions/purchase_price_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("value") + end + + it "has the correct header" do + expect(question.header).to eq("What is the full purchase price?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Purchase price") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has correct width" do + expect(question.width).to eq(5) + end + + it "has correct prefix" do + expect(question.prefix).to eq("£") + end + + it "has correct min" do + expect(question.min).to eq(0) + end +end diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index 49626d81b..96a26ff93 100644 --- a/spec/models/form/sales/subsections/outright_sale_spec.rb +++ b/spec/models/form/sales/subsections/outright_sale_spec.rb @@ -13,10 +13,9 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do it "has correct pages" do expect(outright_sale.pages.map(&:id)).to eq( - %w[ - mortgage_amount_outright_sale - about_deposit_outright_sale - ], + %w[purchase_price + mortgage_amount_outright_sale + about_deposit_outright_sale], ) end 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 345b77675..f0be547da 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -21,8 +21,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do la_nominations buyer_previous previous_bedrooms - about_price - about_price_social_housing + about_price_shared_ownership mortgage_amount_shared_ownership about_deposit_shared_ownership monthly_rent