Browse Source

CLDC-4164, CLDC-4165: Update purchase price minimum to £15,000 for 2026 onwards (#3198)

* CLDC-4164: Update purchase price minimum to £15,000 for 2026 onwards

* CLDC-4164: Apply £15,000 minimum validation to shared ownership purchase price

* CLDC-4164: Update tests

* fixup! CLDC-4164: Update tests

add min tests for 25 and 26
pull/3229/head^2
Samuel Young 1 week ago committed by GitHub
parent
commit
5ce2d0cb47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/sales/questions/purchase_price.rb
  2. 2
      app/models/form/sales/questions/value.rb
  3. 2
      spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb
  4. 2
      spec/models/form/sales/pages/purchase_price_spec.rb
  5. 2
      spec/models/form/sales/pages/value_shared_ownership_spec.rb
  6. 23
      spec/models/form/sales/questions/purchase_price_spec.rb
  7. 19
      spec/models/form/sales/questions/value_spec.rb

2
app/models/form/sales/questions/purchase_price.rb

@ -3,7 +3,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
super(id, hsh, page)
@id = "value"
@type = "numeric"
@min = 0
@min = form.start_year_2026_or_later? ? 15_000 : 0
@step = 0.01
@width = 5
@prefix = "£"

2
app/models/form/sales/questions/value.rb

@ -4,7 +4,7 @@ class Form::Sales::Questions::Value < ::Form::Question
@id = "value"
@copy_key = form.start_year_2025_or_later? ? "sales.sale_information.value.#{page.id}" : "sales.sale_information.value"
@type = "numeric"
@min = 0
@min = form.start_year_2026_or_later? ? 15_000 : 0
@step = 1
@width = 5
@prefix = "£"

2
spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb

@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::PurchasePriceOutrightOwnership, type: :model
let(:page_id) { "purchase_price" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2026_or_later?: false)) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)

2
spec/models/form/sales/pages/purchase_price_spec.rb

@ -8,7 +8,7 @@ RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do
let(:subsection) { instance_double(Form::Subsection) }
before do
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
allow(subsection).to receive(:form).and_return(instance_double(Form, start_year_2024_or_later?: false, start_year_2026_or_later?: false, start_date: Time.zone.local(2023, 4, 1)))
end
it "has correct subsection" do

2
spec/models/form/sales/pages/value_shared_ownership_spec.rb

@ -5,7 +5,7 @@ RSpec.describe Form::Sales::Pages::ValueSharedOwnership, type: :model do
let(:page_id) { "value_shared_ownership" }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "shared_ownership") }
let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2026_or_later?: false), id: "shared_ownership") }
before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(false)

23
spec/models/form/sales/questions/purchase_price_spec.rb

@ -1,11 +1,15 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 1) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) }
let(:start_year) { current_collection_start_year }
let(:start_year_2026_or_later?) { false }
let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: collection_start_date_for_year(start_year), start_year_2026_or_later?: start_year_2026_or_later?))) }
it "has correct page" do
expect(question.page).to eq(page)
@ -30,6 +34,8 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
context "when discounted ownership scheme" do
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 2) }
let(:start_year) { 2023 }
it "has the correct question_number" do
expect(question.question_number).to eq(100)
end
@ -38,6 +44,8 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
context "when outright sale" do
subject(:question) { described_class.new(question_id, question_definition, page, ownershipsch: 3) }
let(:start_year) { 2023 }
it "has the correct question_number" do
expect(question.question_number).to eq(110)
end
@ -51,7 +59,20 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
expect(question.prefix).to eq("£")
end
context "with year 2025", metadata: { year: 25 } do
let(:start_year) { 2025 }
it "has correct min" do
expect(question.min).to eq(0)
end
end
context "with year 2026", metadata: { year: 26 } do
let(:start_year) { 2026 }
let(:start_year_2026_or_later?) { true }
it "has correct min" do
expect(question.min).to eq(15_000)
end
end
end

19
spec/models/form/sales/questions/value_spec.rb

@ -1,11 +1,15 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::Value, type: :model do
include CollectionTimeHelper
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page, id: "value_shared_ownership", subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)), id: "shared_ownership")) }
let(:start_year) { current_collection_start_year }
let(:start_year_2026_or_later?) { false }
let(:page) { instance_double(Form::Page, id: "value_shared_ownership", subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: collection_start_date_for_year(start_year), start_year_2026_or_later?: start_year_2026_or_later?), id: "shared_ownership")) }
before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(false)
@ -35,7 +39,20 @@ RSpec.describe Form::Sales::Questions::Value, type: :model do
expect(question.prefix).to eq("£")
end
context "with year 2025", metadata: { year: 25 } do
let(:start_year) { 2025 }
it "has correct min" do
expect(question.min).to eq(0)
end
end
context "with year 2026", metadata: { year: 26 } do
let(:start_year) { 2026 }
let(:start_year_2026_or_later?) { true }
it "has correct min" do
expect(question.min).to eq(15_000)
end
end
end

Loading…
Cancel
Save