Compare commits

...

3 Commits

  1. 7
      app/models/validations/household_validations.rb
  2. 3
      config/locales/validations/lettings/household.en.yml
  3. 8
      spec/models/validations/household_validations_spec.rb

7
app/models/validations/household_validations.rb

@ -30,13 +30,6 @@ module Validations::HouseholdValidations
end
validate_other_field(record, 20, :reason, :reasonother)
if record.is_reason_permanently_decanted?
if record.referral.present? && !record.is_internal_transfer?
record.errors.add :referral, I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted")
record.errors.add :reason, I18n.t("validations.lettings.household.reason.leaving_last_settled_home.not_internal_transfer")
end
end
return unless record.form.start_year_2024_or_later?
if record.reason == 20 && PHRASES_INDICATING_HOMELESSNESS_REGEX.match?(record.reasonother)

3
config/locales/validations/lettings/household.en.yml

@ -28,7 +28,6 @@ en:
reason:
leaving_last_settled_home:
dont_know_required: "Answer must be ‘don’t know’ as you told us you don’t know the tenant’s main reason for leaving."
not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer."
other_not_settled: "Please give the reason for the tenant leaving their last settled home. This is where they were living before they became homeless, were living in temporary accommodation or sleeping rough."
condition_effects:
@ -102,7 +101,5 @@ en:
referral:
prevten_invalid: "Answer cannot be internal transfer as the household situation immediately before this letting was %{prevten}."
leaving_last_settled_home:
reason_permanently_decanted: "Answer must be internal transfer as the tenant was permanently decanted from another property owned by this landlord."
la_general_needs:
internal_transfer: "Answer cannot be internal transfer as 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."

8
spec/models/validations/household_validations_spec.rb

@ -116,17 +116,17 @@ RSpec.describe Validations::HouseholdValidations do
end
context "when referral is not internal transfer" do
it "cannot be permanently decanted from another property owned by this landlord" do
it "can be permanently decanted from another property owned by this landlord" do
record.reason = 1
record.referral_type = 1
record.referral = 2
household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reason"])
.to include(match(I18n.t("validations.lettings.household.reason.leaving_last_settled_home.not_internal_transfer")))
.to be_empty
expect(record.errors["referral"])
.to include(match(I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted")))
.to be_empty
expect(record.errors["referral_type"])
.to include(match(I18n.t("validations.lettings.household.referral_type.leaving_last_settled_home.reason_permanently_decanted")))
.to be_empty
end
end

Loading…
Cancel
Save