diff --git a/app/models/constants/case_log.rb b/app/models/constants/case_log.rb index c429ffa0e..6d3f46e1e 100644 --- a/app/models/constants/case_log.rb +++ b/app/models/constants/case_log.rb @@ -164,7 +164,7 @@ module Constants::CaseLog }.freeze RSNVAC = { - "Internal transfer (excluding renewals of a fixed-term tenancy)" => 13, + "Internal transfer" => 13, "Previous tenant died with no succession" => 5, "Re-let to tenant who occupied same property as temporary accommodation" => 9, "Renewal of fixed-term tenancy" => 14, diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 6849c79fe..24cb07b7a 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -74,8 +74,9 @@ module Validations::HouseholdValidations end def validate_referral(record) - if record.tenancy == "Secure (including flexible)" && record.referral.present? && record.referral != "Internal transfer" - record.errors.add :referral, I18n.t("validations.household.referral.secure_tenancy") + if record.referral.present? && record.tenancy.present? && record.referral != "Internal transfer" && record.tenancy == "Secure (including flexible)" + record.errors.add :referral, I18n.t("validations.household.referral.secure_tenancy") + record.errors.add :tenancy, I18n.t("validations.tenancy.cannot_be_internal_transfer") end end diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb index 2a3dff1cc..3fe0f9c45 100644 --- a/app/models/validations/tenancy_validations.rb +++ b/app/models/validations/tenancy_validations.rb @@ -26,9 +26,10 @@ module Validations::TenancyValidations validate_other_field(record, :tenancy, :tenancyother) end - def validate_tenancy(record) + def validate_tenancy_type(record) if record.tenancy.present? && record.tenancy != "Secure (including flexible)" && record.referral == "Internal transfer" - record.errors.add :tenancy, I18n.t("validations.tenancy.internal_referral") + record.errors.add :tenancy, I18n.t("validations.tenancy.internal_transfer") + record.errors.add :referral, I18n.t("validations.household.referral.cannot_be_secure_tenancy") end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index f8e1ac01d..2fe73f04c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -113,13 +113,15 @@ en: referral: 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" + cannot_be_secure_tenancy: "Answer cannot be secure tenancy as you already told us this is not an internal transfer" tenancy: length: fixed_term_not_required: "You must only answer the fixed term tenancy length question if the tenancy type is fixed term" shorthold: "Fixed term – Assured Shorthold Tenancy (AST) should be between 2 and 99 years" secure: "Secure (including flexible) should be between 2 and 99 years or not specified" - internal_referral: "Answer must be secure tenancy as you already told us this tenancy is an internal transfer" + internal_transfer: "Answer must be secure tenancy as you already told us this tenancy is an internal transfer" + cannot_be_internal_transfer: "Answer cannot be internal transfer as you already told us this is not a secure tenancy" declaration: missing: "You must show the DLUHC privacy notice to the tenant before you can submit this log." diff --git a/spec/models/validations/tenancy_validations_spec.rb b/spec/models/validations/tenancy_validations_spec.rb index f78b1c4a5..97e55cb59 100644 --- a/spec/models/validations/tenancy_validations_spec.rb +++ b/spec/models/validations/tenancy_validations_spec.rb @@ -113,7 +113,7 @@ RSpec.describe Validations::TenancyValidations do record.referral = "Internal transfer" tenancy_validator.validate_tenancy(record) expect(record.errors["tenancy"]) - .to include(match I18n.t("validations.tenancy.internal_referral")) + .to include(match I18n.t("validations.tenancy.internal_transfer")) end end