Browse Source

Change about_price to purchase_price and display it for outright sale

pull/1135/head
Kat 3 years ago
parent
commit
ae36b76d0e
  1. 18
      app/models/form/sales/pages/about_price.rb
  2. 15
      app/models/form/sales/pages/purchase_price.rb
  3. 14
      app/models/form/sales/questions/purchase_price.rb
  4. 1
      app/models/form/sales/subsections/outright_sale.rb
  5. 10
      spec/models/form/sales/pages/purchase_price_spec.rb
  6. 49
      spec/models/form/sales/questions/purchase_price_spec.rb
  7. 2
      spec/models/form/sales/subsections/outright_sale_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

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
@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),
]

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

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

2
spec/models/form/sales/subsections/outright_sale_spec.rb

@ -13,7 +13,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
%w[
%w[purchase_price
mortgage_amount_outright_sale
about_deposit_outright_sale
],

Loading…
Cancel
Save