Browse Source

Add local housing authority referral validation (#456)

* Add local housing authority referral validation

* Update validation message
pull/457/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
258626d5a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/models/case_log.rb
  2. 4
      app/models/validations/household_validations.rb
  3. 2
      config/locales/en.yml
  4. 18
      spec/models/validations/household_validations_spec.rb

8
app/models/case_log.rb

@ -274,6 +274,14 @@ class CaseLog < ApplicationRecord
landlord == 1
end
def other_landlord?
landlord == 2
end
def local_housing_referral?
referral == 3
end
def is_prevten_la_general_needs?
[30, 31].any?(prevten)
end

4
app/models/validations/household_validations.rb

@ -109,6 +109,10 @@ module Validations::HouseholdValidations
record.errors.add :referral, I18n.t("validations.household.referral.la_general_needs.internal_transfer")
record.errors.add :prevten, I18n.t("validations.household.prevten.la_general_needs.internal_transfer")
end
if record.other_landlord? && record.local_housing_referral?
record.errors.add :referral, I18n.t("validations.household.referral.prp.local_housing_referral")
end
end
def validate_prevloc(record)

2
config/locales/en.yml

@ -191,6 +191,8 @@ en:
reason_permanently_decanted: "Answer must be internal transfer as you already told us the tenant was permanently decanted from another property owned by this landlord"
la_general_needs:
internal_transfer: "Answer cannot be internal transfer as you already told us it's the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting"
prp:
local_housing_referral: "Answer cannot be 'nominated by a local housing authority' as you already told us it's another landlord on the tenancy agreement"
homeless:
assessed:
internal_transfer: "Answer cannot be assessed as homeless as you already told us this tenancy is an internal transfer"

18
spec/models/validations/household_validations_spec.rb

@ -215,6 +215,24 @@ RSpec.describe Validations::HouseholdValidations do
.to include(match(I18n.t("validations.household.prevten.la_general_needs.internal_transfer")))
end
end
context "when referral is nominated by a local housing authority" do
it "cannot have `other landlord`" do
record.landlord = 2
record.referral = 3
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match(I18n.t("validations.household.referral.prp.local_housing_referral")))
end
it "can have `this landlord`" do
record.referral = 3
record.landlord = 1
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to be_empty
end
end
end
describe "armed forces validations" do

Loading…
Cancel
Save