From 8452c9fab17d6401b1490f844dddc4ed348f563e Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 30 Jan 2023 11:47:53 +0000 Subject: [PATCH] feat: use old min/max bedrooms validations --- .../form/sales/questions/property_number_of_bedrooms.rb | 2 ++ app/models/validations/sales/property_validations.rb | 8 -------- config/locales/en.yml | 1 - .../sales/questions/property_number_of_bedrooms_spec.rb | 4 ++-- 4 files changed, 4 insertions(+), 11 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 7165921f5..e8ea674ea 100644 --- a/app/models/form/sales/questions/property_number_of_bedrooms.rb +++ b/app/models/form/sales/questions/property_number_of_bedrooms.rb @@ -7,5 +7,7 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question @hint_text = "A bedsit has 1 bedroom" @type = "numeric" @width = 10 + @min = 1 + @max = 9 end end diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb index 2c9473b16..879e37ff1 100644 --- a/app/models/validations/sales/property_validations.rb +++ b/app/models/validations/sales/property_validations.rb @@ -7,12 +7,4 @@ module Validations::Sales::PropertyValidations record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous") end end - - def validate_bedroom_number(record) - return unless record.beds - - unless record.beds.between?(1, 9) - record.errors.add :beds, I18n.t("validations.property.beds.1_9") - end - end end diff --git a/config/locales/en.yml b/config/locales/en.yml index b95de8b0e..c94f589ba 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -195,7 +195,6 @@ en: beds: non_positive: "Number of bedrooms has to be greater than 0" over_max: "Number of bedrooms cannot be more than 12" - 1_9: "Bedroom number must be 1-9" postcode: must_match_previous: "Buyer's last accommodation and discounted ownership postcodes must match" 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 93b6eaad6..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 @@ -36,10 +36,10 @@ RSpec.describe Form::Sales::Questions::PropertyNumberOfBedrooms, type: :model do end it "has the correct min" do - expect(question.min).to eq(nil) + expect(question.min).to eq(1) end it "has the correct max" do - expect(question.max).to eq(nil) + expect(question.max).to eq(9) end end