Browse Source

add homelessness validation (#319)

pull/324/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
cd882d322f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/models/validations/household_validations.rb
  2. 8
      config/locales/en.yml
  3. 40
      spec/models/validations/household_validations_spec.rb

10
app/models/validations/household_validations.rb

@ -78,6 +78,16 @@ module Validations::HouseholdValidations
record.errors.add :referral, I18n.t("validations.household.referral.secure_tenancy") record.errors.add :referral, I18n.t("validations.household.referral.secure_tenancy")
record.errors.add :tenancy, I18n.t("validations.tenancy.cannot_be_internal_transfer") record.errors.add :tenancy, I18n.t("validations.tenancy.cannot_be_internal_transfer")
end end
if record.referral == "Internal transfer" && record.homeless == "Assessed as homeless (or threatened with homelessness within 56 days) by a local authority and owed a homelessness duty"
record.errors.add :referral, I18n.t("validations.household.referral.assessed_homeless")
record.errors.add :homeless, I18n.t("validations.household.homeless.assessed.internal_transfer")
end
if record.referral == "Internal transfer" && record.homeless == "Other homeless - not found statutorily homeless but considered homeless by landlord"
record.errors.add :referral, I18n.t("validations.household.referral.other_homeless")
record.errors.add :homeless, I18n.t("validations.household.homeless.other.internal_transfer")
end
end end
private private

8
config/locales/en.yml

@ -114,6 +114,14 @@ en:
secure_tenancy: "Answer must be internal transfer as you already told us this is a secure tenancy" secure_tenancy: "Answer must be internal transfer as you already told us this is a secure tenancy"
rsnvac_non_temp: "Answer cannot be this source of referral as you already told us this is a re-let to tenant who occupied the same property as temporary accommodation" rsnvac_non_temp: "Answer cannot be this source of referral as you already told us this is a re-let to tenant who occupied the same property as temporary accommodation"
cannot_be_secure_tenancy: "Answer cannot be secure tenancy as you already told us this is not an internal transfer" cannot_be_secure_tenancy: "Answer cannot be secure tenancy as you already told us this is not an internal transfer"
assessed_homeless: "Answer cannot be internal transfer as you already told us the tenant was assessed as homeless"
other_homeless: "Answer cannot be internal transfer as you already told us the tenant was considered homeless by their landlord"
homeless:
assessed:
internal_transfer: "Answer cannot be assessed as homeless as you already told us this tenancy is an internal transfer"
other:
internal_transfer: "Answer cannot be other homelessness as you already told us this tenancy was an internal transfer"
tenancy: tenancy:
length: length:

40
spec/models/validations/household_validations_spec.rb

@ -495,5 +495,45 @@ RSpec.describe Validations::HouseholdValidations do
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
end end
end end
context "when homelessness is assessed" do
it "cannot be internal transfer" do
record.homeless = "Assessed as homeless (or threatened with homelessness within 56 days) by a local authority and owed a homelessness duty"
record.referral = "Internal transfer"
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match I18n.t("validations.household.referral.assessed_homeless"))
expect(record.errors["homeless"])
.to include(match I18n.t("validations.household.homeless.assessed.internal_transfer"))
end
it "can be non internal transfer" do
record.homeless = "Assessed as homeless (or threatened with homelessness within 56 days) by a local authority and owed a homelessness duty"
record.referral = "Other social landlord"
household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty
expect(record.errors["homeless"]).to be_empty
end
end
context "when homelessness is other" do
it "cannot be internal transfer" do
record.referral = "Internal transfer"
record.homeless = "Other homeless - not found statutorily homeless but considered homeless by landlord"
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match I18n.t("validations.household.referral.other_homeless"))
expect(record.errors["homeless"])
.to include(match I18n.t("validations.household.homeless.other.internal_transfer"))
end
it "can be non internal transfer" do
record.referral = "Other social landlord"
record.homeless = "Other homeless - not found statutorily homeless but considered homeless by landlord"
household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty
expect(record.errors["homeless"]).to be_empty
end
end
end end
end end

Loading…
Cancel
Save