Browse Source

Update london postcode validation error message

pull/390/head
baarkerlounger 3 years ago
parent
commit
b9a5ac80c3
  1. 2
      app/models/validations/property_validations.rb
  2. 1
      config/locales/en.yml
  3. 2
      spec/models/validations/property_validations_spec.rb

2
app/models/validations/property_validations.rb

@ -58,7 +58,7 @@ module Validations::PropertyValidations
if record.la.present? && !LONDON_BOROUGHS.include?(record.la) && record.is_london_rent?
record.errors.add :la, I18n.t("validations.property.la.london_rent")
if record.postcode_known? && record.property_postcode.present?
record.errors.add :property_postcode, I18n.t("validations.property.la.london_rent")
record.errors.add :property_postcode, I18n.t("validations.property.la.london_rent_postcode")
end
end

1
config/locales/en.yml

@ -61,6 +61,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"
london_rent_postcode: "The postcode must be a London postcode because you told us the rent type is London Affordable Rent or London Living Rent"
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"

2
spec/models/validations/property_validations_spec.rb

@ -167,6 +167,8 @@ RSpec.describe Validations::PropertyValidations do
end
context "when the la has been derived from a known postcode" do
let(:expected_error) { I18n.t("validations.property.la.london_rent_postcode") }
it "also adds an error to the postcode field" do
record.la = "E07000105"
record.rent_type = 2

Loading…
Cancel
Save