diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index 81549c011..b0faf22cf 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -4,6 +4,7 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question @id = "mortgage" @type = "numeric" @min = 1 + @max = form.start_year_2026_or_later? ? 999_999 : nil @step = 1 @width = 5 @prefix = "£" diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index 24aecd7ec..3d559a3bb 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -4,6 +4,7 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question @id = "value" @type = "numeric" @min = form.start_year_2026_or_later? ? 15_000 : 0 + @max = form.start_year_2026_or_later? ? 999_999 : nil @step = 0.01 @width = 5 @prefix = "£" diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb index 0884a3fb6..9e6a6dec7 100644 --- a/app/models/form/sales/questions/value.rb +++ b/app/models/form/sales/questions/value.rb @@ -5,6 +5,7 @@ class Form::Sales::Questions::Value < ::Form::Question @copy_key = form.start_year_2025_or_later? ? "sales.sale_information.value.#{page.id}" : "sales.sale_information.value" @type = "numeric" @min = form.start_year_2026_or_later? ? 15_000 : 0 + @max = form.start_year_2026_or_later? ? 999_999 : nil @step = 1 @width = 10 @prefix = "£" diff --git a/spec/models/form/sales/questions/mortgage_amount_spec.rb b/spec/models/form/sales/questions/mortgage_amount_spec.rb index 12da4bc1f..d6ed4d740 100644 --- a/spec/models/form/sales/questions/mortgage_amount_spec.rb +++ b/spec/models/form/sales/questions/mortgage_amount_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Questions::MortgageAmount, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, id: "shared_ownership_initial_purchase", form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2026_or_later?: false))) } + let(:start_year_2026_or_later?) { false } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, id: "shared_ownership_initial_purchase", form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_2026_or_later?: start_year_2026_or_later?))) } it "has correct page" do expect(question.page).to be(page) @@ -50,4 +51,28 @@ RSpec.describe Form::Sales::Questions::MortgageAmount, type: :model do expect(question).not_to be_derived(log) end end + + context "with year 2025", metadata: { year: 25 } do + let(:start_year_2026_or_later?) { false } + + it "has correct min" do + expect(question.min).to eq(1) + end + + it "has correct max" do + expect(question.max).to be_nil + end + end + + context "with year 2026", metadata: { year: 26 } do + let(:start_year_2026_or_later?) { true } + + it "has correct min" do + expect(question.min).to eq(1) + end + + it "has correct max" do + expect(question.max).to eq(999_999) + end + end end diff --git a/spec/models/form/sales/questions/purchase_price_spec.rb b/spec/models/form/sales/questions/purchase_price_spec.rb index 47081edb4..ac50668aa 100644 --- a/spec/models/form/sales/questions/purchase_price_spec.rb +++ b/spec/models/form/sales/questions/purchase_price_spec.rb @@ -65,6 +65,10 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do it "has correct min" do expect(question.min).to eq(0) end + + it "has correct max" do + expect(question.max).to be_nil + end end context "with year 2026", metadata: { year: 26 } do @@ -74,5 +78,9 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do it "has correct min" do expect(question.min).to eq(15_000) end + + it "has correct max" do + expect(question.max).to eq(999_999) + end end end diff --git a/spec/models/form/sales/questions/value_spec.rb b/spec/models/form/sales/questions/value_spec.rb index 952b02e7c..057762833 100644 --- a/spec/models/form/sales/questions/value_spec.rb +++ b/spec/models/form/sales/questions/value_spec.rb @@ -45,6 +45,10 @@ RSpec.describe Form::Sales::Questions::Value, type: :model do it "has correct min" do expect(question.min).to eq(0) end + + it "has correct max" do + expect(question.max).to be_nil + end end context "with year 2026", metadata: { year: 26 } do @@ -54,5 +58,9 @@ RSpec.describe Form::Sales::Questions::Value, type: :model do it "has correct min" do expect(question.min).to eq(15_000) end + + it "has correct max" do + expect(question.max).to eq(999_999) + end end end