Browse Source

CLDC-4333: set hard min to 0 for staircasing

pull/3270/head
Nat Dean-Lewis 1 week ago
parent
commit
0e5edb9ca2
  1. 6
      app/models/form/sales/questions/value.rb
  2. 14
      spec/models/form/sales/questions/value_spec.rb

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

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

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

@ -55,4 +55,18 @@ RSpec.describe Form::Sales::Questions::Value, type: :model do
expect(question.min).to eq(15_000) expect(question.min).to eq(15_000)
end end
end end
context "with year 2026 and staircasing subsection", metadata: { year: 26 } do
let(:start_year) { 2026 }
let(:start_year_2026_or_later?) { true }
let(:page) { instance_double(Form::Page, id: "value_shared_ownership_staircase", 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_staircasing_transaction")) }
before do
allow(page.subsection.form).to receive(:start_year_2025_or_later?).and_return(true)
end
it "has correct min" do
expect(question.min).to eq(0)
end
end
end end

Loading…
Cancel
Save