Browse Source

Update case log constants to match JSON form config

pull/317/head
Paul Robert Lloyd 3 years ago
parent
commit
fd2ab86723
  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 }.freeze
RSNVAC = { 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, "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, "Renewal of fixed-term tenancy" => 14,
"Tenant moved to care home" => 18,
"Tenant involved in a succession downsize" => 19, "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 }.freeze
UNITTYPE_GN = { UNITTYPE_GN = {

2
app/models/validations/household_validations.rb

@ -68,7 +68,7 @@ module Validations::HouseholdValidations
end end
def validate_previous_housing_situation(record) 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") record.errors.add :prevten, I18n.t("validations.household.prevten.non_temp_accommodation")
end end
end end

2
app/models/validations/local_authority_validations.rb

@ -11,7 +11,7 @@ module Validations::LocalAuthorityValidations
end end
def validate_referral(record) 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") record.errors.add :referral, I18n.t("validations.local_authority.referral.rsnvac_non_temp")
end end
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") record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.first_let_social")
end 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") record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.non_temp_accommodation")
end 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") record.errors.add :rsnvac, I18n.t("validations.property.rsnvac.referral_invalid")
end end
end end

18
config/forms/2021_2022.json

@ -667,26 +667,26 @@
"0": { "0": {
"value": "Renewal of fixed-term tenancy" "value": "Renewal of fixed-term tenancy"
}, },
"7": {
"value": "Tenant abandoned property"
},
"3": { "3": {
"value": "Tenant involved in a succession downsize" "value": "Tenant involved in a succession downsize"
}, },
"4": { "6": {
"value": "Tenant moved to private sector or other accommodation" "value": "Tenant moved to care home"
}, },
"5": { "5": {
"value": "Tenant moved to other social housing provider" "value": "Tenant moved to other social housing provider"
}, },
"6": { "4": {
"value": "Tenant moved to care home" "value": "Tenant moved to private sector or other accommodation"
}, },
"7": { "9": {
"value": "Tenant abandoned property" "value": "Tenant was evicted due to anti-social behaviour"
}, },
"8": { "8": {
"value": "Tenant was evicted due to rent arrears" "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 it "validates that the property is not being relet to tenant who occupied as temporary" do
non_temporary_previous_tenancies.each do |rsn| 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 record.prevten = rsn
property_validator.validate_rsnvac(record) property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"]) expect(record.errors["rsnvac"])
@ -269,7 +269,7 @@ RSpec.describe Validations::PropertyValidations do
it "validates that the letting source is not a referral" do it "validates that the letting source is not a referral" do
referral_sources.each do |src| 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 record.referral = src
property_validator.validate_rsnvac(record) property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"]) expect(record.errors["rsnvac"])
@ -281,7 +281,7 @@ RSpec.describe Validations::PropertyValidations do
context "when the previous tenancy was temporary" 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 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.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) property_validator.validate_rsnvac(record)
expect(record.errors["rsnvac"]).to be_empty expect(record.errors["rsnvac"]).to be_empty
end end

Loading…
Cancel
Save