From c035b905f5f3346035dc3a895af1ef80337398b1 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 23 Jan 2023 12:56:52 +0000 Subject: [PATCH] Number of bedrooms must be between 1 and 9 (#1212) --- .../sales/questions/property_number_of_bedrooms.rb | 4 +++- .../questions/property_number_of_bedrooms_spec.rb | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/form/sales/questions/property_number_of_bedrooms.rb b/app/models/form/sales/questions/property_number_of_bedrooms.rb index d06d943cf..e8ea674ea 100644 --- a/app/models/form/sales/questions/property_number_of_bedrooms.rb +++ b/app/models/form/sales/questions/property_number_of_bedrooms.rb @@ -5,7 +5,9 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question @check_answer_label = "Number of bedrooms" @header = "How many bedrooms does the property have?" @hint_text = "A bedsit has 1 bedroom" - @type = "text" + @type = "numeric" @width = 10 + @min = 1 + @max = 9 end end diff --git a/spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb b/spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb index fc8dc3989..cad7cb004 100644 --- a/spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb +++ b/spec/models/form/sales/questions/property_number_of_bedrooms_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Questions::PropertyNumberOfBedrooms, type: :model do end it "has the correct type" do - expect(question.type).to eq("text") + expect(question.type).to eq("numeric") end it "is not marked as derived" do @@ -34,4 +34,12 @@ RSpec.describe Form::Sales::Questions::PropertyNumberOfBedrooms, type: :model do it "has the correct hint_text" do expect(question.hint_text).to eq("A bedsit has 1 bedroom") end + + it "has the correct min" do + expect(question.min).to eq(1) + end + + it "has the correct max" do + expect(question.max).to eq(9) + end end