Browse Source

add la validation to the property information section

pull/332/head
Kat 3 years ago
parent
commit
6e45b235ec
  1. 4
      app/models/validations/property_validations.rb
  2. 1
      config/locales/en.yml
  3. 9
      spec/models/validations/property_validations_spec.rb

4
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",

1
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"

9
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

Loading…
Cancel
Save