diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index 107460dec..26b569f85 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -27,6 +27,10 @@ module Validations::PropertyValidations if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && (record.rent_type == "London Affordable rent" || record.rent_type == "London living rent") record.errors.add :la, I18n.t("validations.property.la.london_rent") end + + if record.la_known == "Yes" && record.la.blank? + record.errors.add :la, I18n.t("validations.property.la.la_known") + end end FIRST_LET_VACANCY_REASONS = ["First let of new-build property", diff --git a/config/locales/en.yml b/config/locales/en.yml index 9a5b8fad9..71bebaf85 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,6 +55,7 @@ en: relet_number: "Property number of times relet must be between 0 and 20" la: london_rent: "Local authority has to be in London" + la_known: "Enter a local authority" rsnvac: first_let_not_social: "Reason for vacancy cannot be first let if unit has been previously let as social housing" first_let_social: "Reason for vacancy must be first let if unit has been previously let as social housing" diff --git a/spec/models/validations/property_validations_spec.rb b/spec/models/validations/property_validations_spec.rb index fb11039c9..bbf650059 100644 --- a/spec/models/validations/property_validations_spec.rb +++ b/spec/models/validations/property_validations_spec.rb @@ -157,6 +157,15 @@ RSpec.describe Validations::PropertyValidations do expect(record.errors["la"]).to be_empty end end + + context "when previous la is known" do + it "la has to be provided" do + record.la_known = "Yes" + property_validator.validate_la(record) + expect(record.errors["la"]) + .to include(match I18n.t("validations.property.la.la_known")) + end + end end describe "#validate_unitletas" do