Browse Source

Cldc 1540 fixes part two (#1135)

* Change about_price_social_housing to about_price_shared_ownership and display it in all shared ownership cases

* Change about_price to purchase_price and display it for outright sale

* lint
pull/1143/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
f96389f60f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      app/models/form/sales/pages/about_price.rb
  2. 7
      app/models/form/sales/pages/about_price_shared_ownership.rb
  3. 15
      app/models/form/sales/pages/purchase_price.rb
  4. 14
      app/models/form/sales/questions/purchase_price.rb
  5. 1
      app/models/form/sales/subsections/outright_sale.rb
  6. 3
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  7. 8
      spec/models/form/sales/pages/about_price_shared_ownership_spec.rb
  8. 10
      spec/models/form/sales/pages/purchase_price_spec.rb
  9. 49
      spec/models/form/sales/questions/purchase_price_spec.rb
  10. 7
      spec/models/form/sales/subsections/outright_sale_spec.rb
  11. 3
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

18
app/models/form/sales/pages/about_price.rb

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

7
app/models/form/sales/pages/about_price_social_housing.rb → 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) def initialize(id, hsh, subsection)
super super
@id = "about_price_social_housing" @id = "about_price_shared_ownership"
@header = "About the price of the property" @header = "About the price of the property"
@description = "" @description = ""
@subsection = subsection @subsection = subsection
@depends_on = [{
"soctenant" => 1,
}]
end end
def questions def questions

15
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

14
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

1
app/models/form/sales/subsections/outright_sale.rb

@ -9,6 +9,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
def pages def pages
@pages ||= [ @pages ||= [
Form::Sales::Pages::PurchasePrice.new(nil, nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self),
Form::Sales::Pages::AboutDeposit.new("about_deposit_outright_sale", nil, self), Form::Sales::Pages::AboutDeposit.new("about_deposit_outright_sale", nil, self),
] ]

3
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::LaNominations.new(nil, nil, self),
Form::Sales::Pages::BuyerPrevious.new(nil, nil, self), Form::Sales::Pages::BuyerPrevious.new(nil, nil, self),
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self), Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self),
Form::Sales::Pages::AboutPrice.new(nil, nil, self), Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self),
Form::Sales::Pages::AboutPriceSocialHousing.new(nil, nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", 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::AboutDeposit.new("about_deposit_shared_ownership", nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self),

8
spec/models/form/sales/pages/about_price_social_housing_spec.rb → spec/models/form/sales/pages/about_price_shared_ownership_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" 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) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil } let(:page_id) { nil }
@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceSocialHousing, type: :model do
end end
it "has the correct id" do 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 end
it "has the correct header" do it "has the correct header" do
@ -28,8 +28,6 @@ RSpec.describe Form::Sales::Pages::AboutPriceSocialHousing, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ expect(page.depends_on).to be_nil
"soctenant" => 1,
}])
end end
end end

10
spec/models/form/sales/pages/about_price_spec.rb → spec/models/form/sales/pages/purchase_price_spec.rb

@ -1,6 +1,6 @@
require "rails_helper" 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) } subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil } let(:page_id) { nil }
@ -16,11 +16,11 @@ RSpec.describe Form::Sales::Pages::AboutPrice, type: :model do
end end
it "has the correct id" do it "has the correct id" do
expect(page.id).to eq("about_price") expect(page.id).to eq("purchase_price")
end end
it "has the correct header" do it "has the correct header" do
expect(page.header).to eq("About the price of the property") expect(page.header).to eq("")
end end
it "has the correct description" do it "has the correct description" do
@ -28,8 +28,6 @@ RSpec.describe Form::Sales::Pages::AboutPrice, type: :model do
end end
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq([{ expect(page.depends_on).to be_nil
"soctenant" => 2,
}])
end end
end end

49
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

7
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 it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq( expect(outright_sale.pages.map(&:id)).to eq(
%w[ %w[purchase_price
mortgage_amount_outright_sale mortgage_amount_outright_sale
about_deposit_outright_sale about_deposit_outright_sale],
],
) )
end end

3
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 la_nominations
buyer_previous buyer_previous
previous_bedrooms previous_bedrooms
about_price about_price_shared_ownership
about_price_social_housing
mortgage_amount_shared_ownership mortgage_amount_shared_ownership
about_deposit_shared_ownership about_deposit_shared_ownership
monthly_rent monthly_rent

Loading…
Cancel
Save