Browse Source

Update internal transfer validation (#1924)

* feat: remove residential care home from internal transfer validation

* feat: update tests

* feat: update tests

* feat: update tests
pull/1919/head
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
647f9fbc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/models/validations/household_validations.rb
  2. 14
      spec/models/validations/household_validations_spec.rb
  3. 4
      spec/services/imports/lettings_logs_import_service_spec.rb

3
app/models/validations/household_validations.rb

@ -69,7 +69,6 @@ module Validations::HouseholdValidations
# 3 Private Sector Tenancy # 3 Private Sector Tenancy
# 4 Tied housing or rented with job # 4 Tied housing or rented with job
# 7 Direct access hostel # 7 Direct access hostel
# 9 Residential care home
# 10 Hospital # 10 Hospital
# 13 Children's home / Foster Care # 13 Children's home / Foster Care
# 14 Bed and breakfast # 14 Bed and breakfast
@ -82,7 +81,7 @@ module Validations::HouseholdValidations
# 27 Owner occupation (low-cost home ownership) # 27 Owner occupation (low-cost home ownership)
# 28 Living with Friends or Family # 28 Living with Friends or Family
# 29 Prison / Approved Probation Hostel # 29 Prison / Approved Probation Hostel
if record.is_internal_transfer? && [3, 4, 7, 9, 10, 13, 14, 19, 21, 23, 24, 25, 26, 27, 28, 29].include?(record.prevten) if record.is_internal_transfer? && [3, 4, 7, 10, 13, 14, 19, 21, 23, 24, 25, 26, 27, 28, 29].include?(record.prevten)
label = record.form.get_question("prevten", record).present? ? record.form.get_question("prevten", record).label_from_value(record.prevten) : "" label = record.form.get_question("prevten", record).present? ? record.form.get_question("prevten", record).label_from_value(record.prevten) : ""
record.errors.add :prevten, :internal_transfer_non_social_housing, message: I18n.t("validations.household.prevten.internal_transfer", prevten: label) record.errors.add :prevten, :internal_transfer_non_social_housing, message: I18n.t("validations.household.prevten.internal_transfer", prevten: label)
record.errors.add :referral, :internal_transfer_non_social_housing, message: I18n.t("validations.household.referral.prevten_invalid", prevten: label) record.errors.add :referral, :internal_transfer_non_social_housing, message: I18n.t("validations.household.referral.prevten_invalid", prevten: label)

14
spec/models/validations/household_validations_spec.rb

@ -619,7 +619,17 @@ RSpec.describe Validations::HouseholdValidations do
end end
context "when the referral is internal transfer" do context "when the referral is internal transfer" do
it "cannot be 3" do it "prevten can be 9" do
record.referral = 1
record.prevten = 9
household_validator.validate_previous_housing_situation(record)
expect(record.errors["prevten"])
.to be_empty
expect(record.errors["referral"])
.to be_empty
end
it "prevten cannot be 3" do
record.referral = 1 record.referral = 1
record.prevten = 3 record.prevten = 3
household_validator.validate_previous_housing_situation(record) household_validator.validate_previous_housing_situation(record)
@ -629,7 +639,7 @@ RSpec.describe Validations::HouseholdValidations do
.to include(match I18n.t("validations.household.referral.prevten_invalid", prevten: "")) .to include(match I18n.t("validations.household.referral.prevten_invalid", prevten: ""))
end end
it "cannot be 4, 10, 13, 19, 23, 24, 25, 26, 28, 29" do it "prevten cannot be 4, 10, 13, 19, 23, 24, 25, 26, 28, 29" do
record.referral = 1 record.referral = 1
record.prevten = 4 record.prevten = 4
household_validator.validate_previous_housing_situation(record) household_validator.validate_previous_housing_situation(record)

4
spec/services/imports/lettings_logs_import_service_spec.rb

@ -432,9 +432,9 @@ RSpec.describe Imports::LettingsLogsImportService do
end end
end end
context "and this is an internal transfer from a non social housing" do context "and this is an internal transfer from a non social housing (and not residential care home)" do
before do before do
lettings_log_xml.at_xpath("//xmlns:Q11").content = "9 Residential care home" lettings_log_xml.at_xpath("//xmlns:Q11").content = "4 Tied housing or rented with job"
lettings_log_xml.at_xpath("//xmlns:Q16").content = "1 Internal Transfer" lettings_log_xml.at_xpath("//xmlns:Q16").content = "1 Internal Transfer"
end end

Loading…
Cancel
Save