diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index cd11a5162..ce7c25d2b 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -118,5 +118,9 @@ module Validations::PropertyValidations record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_seven_bedroom_shared") end end + + if record.beds.present? && record.beds > 12 + record.errors.add :beds, I18n.t("validations.property.beds.over_max") + end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 71bebaf85..f161fabbc 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -68,6 +68,7 @@ en: one_three_bedroom_single_tenant_shared: "A shared house with less than two tenants must have 1 to 3 bedrooms" beds: negative: "Number of bedrooms has to be greater than 0" + over_max: "Number of bedrooms cannot be more than 12" financial: tshortfall: diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index fec1e61ef..661b800d6 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -137,6 +137,14 @@ RSpec.describe Validations::PropertyValidations do expect(record.errors["beds"]).to include(I18n.t("validations.property.beds.negative")) end end + + context "when a room number higher than 12 has been entered" do + it "adds an error" do + record.beds = 13 + property_validator.validate_shared_housing_rooms(record) + expect(record.errors["beds"]).to include(I18n.t("validations.property.beds.over_max")) + end + end end describe "#validate_la" do