Browse Source

Merge pull request #317 from communitiesuk/design-audit-4-fixes

Update case log constants to match JSON form config
pull/318/head
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
070405eba0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      app/models/constants/case_log.rb
  2. 2
      app/models/validations/household_validations.rb
  3. 2
      app/models/validations/local_authority_validations.rb
  4. 4
      app/models/validations/property_validations.rb
  5. 18
      config/forms/2021_2022.json
  6. 6
      spec/models/validations/property_validations_spec.rb

22
app/models/constants/case_log.rb

@ -164,20 +164,20 @@ module Constants::CaseLog
}.freeze
RSNVAC = {
"First let of new-build property" => 15,
"First let of conversion, rehabilitation or acquired property" => 16,
"First let of leased property" => 17,
"Tenant evicted due to arrears" => 10,
"Tenant evicted due to ASB or other reason" => 11,
"Previous tenant passed away (no succession)" => 5,
"Tenant moved to other social housing provider" => 12,
"Tenant abandoned property" => 6,
"Tenant moved to private sector or other accommodation" => 8,
"Relet to tenant who occupied same property as temporary accommodation" => 9,
"Internal transfer (excluding renewals of a fixed-term tenancy)" => 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,
"Tenant moved to care home" => 18,
"Tenant involved in a succession downsize" => 19,
"Tenant abandoned property" => 6,
"Tenant moved to care home" => 18,
"Tenant moved to other social housing provider" => 12,
"Tenant moved to private sector or other accommodation" => 8,
"Tenant was evicted due to anti-social behaviour" => 11,
"Tenant was evicted due to rent arrears" => 10,
"First let of new-build property" => 15,
"First let of conversion, rehabilitation or acquired property" => 16,
"First let of leased property" => 17,
}.freeze
UNITTYPE_GN = {

2
app/models/validations/household_validations.rb

@ -68,7 +68,7 @@ module Validations::HouseholdValidations
end
def validate_previous_housing_situation(record)
if record.rsnvac == "Relet to tenant who occupied same property as temporary accommodation" && NON_TEMP_ACCOMMODATION.include?(record.prevten)
if record.rsnvac == "Re-let to tenant who occupied same property as temporary accommodation" && NON_TEMP_ACCOMMODATION.include?(record.prevten)
record.errors.add :prevten, I18n.t("validations.household.prevten.non_temp_accommodation")
end
end

2
app/models/validations/local_authority_validations.rb

@ -11,7 +11,7 @@ module Validations::LocalAuthorityValidations
end
def validate_referral(record)
if record.rsnvac == "Relet to tenant who occupied same property as temporary accommodation" && REFERRAL_INVALID_TMP.include?(record.referral)
if record.rsnvac == "Re-let to tenant who occupied same property as temporary accommodation" && REFERRAL_INVALID_TMP.include?(record.referral)
record.errors.add :referral, I18n.t("validations.local_authority.referral.rsnvac_non_temp")
end
end

4
app/models/validations/property_validations.rb

@ -41,11 +41,11 @@ module Validations::PropertyValidations
record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.first_let_social")
end
if record.rsnvac == "Relet to tenant who occupied same property as temporary accommodation" && NON_TEMP_ACCOMMODATION.include?(record.prevten)
if record.rsnvac == "Re-let to tenant who occupied same property as temporary accommodation" && NON_TEMP_ACCOMMODATION.include?(record.prevten)
record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.non_temp_accommodation")
end
if record.rsnvac == "Relet to tenant who occupied same property as temporary accommodation" && REFERRAL_INVALID_TMP.include?(record.referral)
if record.rsnvac == "Re-let to tenant who occupied same property as temporary accommodation" && REFERRAL_INVALID_TMP.include?(record.referral)
record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.referral_invalid")
end
end

18
config/forms/2021_2022.json

@ -667,26 +667,26 @@
"0": {
"value": "Renewal of fixed-term tenancy"
},
"7": {
"value": "Tenant abandoned property"
},
"3": {
"value": "Tenant involved in a succession downsize"
},
"4": {
"value": "Tenant moved to private sector or other accommodation"
"6": {
"value": "Tenant moved to care home"
},
"5": {
"value": "Tenant moved to other social housing provider"
},
"6": {
"value": "Tenant moved to care home"
"4": {
"value": "Tenant moved to private sector or other accommodation"
},
"7": {
"value": "Tenant abandoned property"
"9": {
"value": "Tenant was evicted due to anti-social behaviour"
},
"8": {
"value": "Tenant was evicted due to rent arrears"
},
"9": {
"value": "Tenant was evicted due to anti-social behaviour"
}
}
}

6
spec/models/validations/property_validations_spec.rb

@ -259,7 +259,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the property is not being relet to tenant who occupied as temporary" do
non_temporary_previous_tenancies.each do |rsn|
record.rsnvac = "Relet to tenant who occupied same property as temporary accommodation"
record.rsnvac = "Re-let to tenant who occupied same property as temporary accommodation"
record.prevten = rsn
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
@ -269,7 +269,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the letting source is not a referral" do
referral_sources.each do |src|
record.rsnvac = "Relet to tenant who occupied same property as temporary accommodation"
record.rsnvac = "Re-let to tenant who occupied same property as temporary accommodation"
record.referral = src
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"])
@ -281,7 +281,7 @@ RSpec.describe Validations::PropertyValidations do
context "when the previous tenancy was temporary" do
it "expects that the property can be relet to a tenant who previously occupied it as temporary" do
record.prevten = "Fixed-term local authority general needs tenancy"
record.rsnvac = "Relet to tenant who occupied same property as temporary accommodation"
record.rsnvac = "Re-let to tenant who occupied same property as temporary accommodation"
property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"]).to be_empty
end

Loading…
Cancel
Save