Browse Source

CLDC-1694 Fix issue with non-renewal lettings allowing 'renewal' for vacancy reason (#982)

* feat: add renewal validation on rsnvac

* test: check sensible error seen when rsnvac is renewal and but letting is not a renewal

* test: change renewal validation check to fetch error message dynamically

* feat: lint code

* feat: write record.renewal.present?, not record.renewal

Co-authored-by: James Rose <james@jbpr.net>

Co-authored-by: James Rose <james@jbpr.net>
pull/985/head
SamSeed-Softwire 2 years ago committed by GitHub
parent
commit
219bf937cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/models/validations/property_validations.rb
  2. 1
      config/locales/en.yml
  3. 11
      spec/models/validations/property_validations_spec.rb

4
app/models/validations/property_validations.rb

@ -38,6 +38,10 @@ module Validations::PropertyValidations
record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.referral_invalid") record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.referral_invalid")
record.errors.add :referral, I18n.t("validations.household.referral.rsnvac_non_temp") record.errors.add :referral, I18n.t("validations.household.referral.rsnvac_non_temp")
end end
if record.renewal.present? && record.renewal.zero? && record.rsnvac == 14
record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.not_a_renewal")
end
end end
def validate_unitletas(record) def validate_unitletas(record)

1
config/locales/en.yml

@ -141,6 +141,7 @@ en:
previous_let_social: "Property cannot have a previous let type if being let as social housing for the first time" previous_let_social: "Property cannot have a previous let type if being let as social housing for the first time"
non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary" non_temp_accommodation: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as this accommodation is not temporary"
referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting" referral_invalid: "Answer cannot be re-let to tenant who occupied the same property as temporary accommodation as a different source of referral for this letting"
not_a_renewal: "Reason for vacancy cannot be 'Renewal of fixed-term tenancy' if letting is not a renewal"
unittype_gn: unittype_gn:
one_bedroom_bedsit: "A bedsit can only have one bedroom" one_bedroom_bedsit: "A bedsit can only have one bedroom"
one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms" one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms"

11
spec/models/validations/property_validations_spec.rb

@ -233,6 +233,17 @@ RSpec.describe Validations::PropertyValidations do
property_validator.validate_rsnvac(record) property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"]).to be_empty expect(record.errors["rsnvac"]).to be_empty
end end
context "when the letting is not a renewal" do
it "validates that the reason for vacancy is not renewal" do
record.first_time_property_let_as_social_housing = 0
record.renewal = 0
record.rsnvac = 14
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
.to include(match I18n.t("validations.property.rsnvac.not_a_renewal"))
end
end
end end
context "when the property has been let before" do context "when the property has been let before" do

Loading…
Cancel
Save