Browse Source

feat: remove residential care home from internal transfer validation

pull/1924/head
natdeanlewissoftwire 3 years ago
parent
commit
01fc50cb60
  1. 3
      app/models/validations/household_validations.rb
  2. 10
      spec/models/validations/household_validations_spec.rb

3
app/models/validations/household_validations.rb

@ -69,7 +69,6 @@ module Validations::HouseholdValidations
# 3 Private Sector Tenancy
# 4 Tied housing or rented with job
# 7 Direct access hostel
# 9 Residential care home
# 10 Hospital
# 13 Children's home / Foster Care
# 14 Bed and breakfast
@ -82,7 +81,7 @@ module Validations::HouseholdValidations
# 27 Owner occupation (low-cost home ownership)
# 28 Living with Friends or Family
# 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) : ""
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)

10
spec/models/validations/household_validations_spec.rb

@ -629,6 +629,16 @@ RSpec.describe Validations::HouseholdValidations do
.to include(match I18n.t("validations.household.referral.prevten_invalid", prevten: ""))
end
it "cannot be 9" do
record.referral = 1
record.prevten = 9
household_validator.validate_previous_housing_situation(record)
expect(record.errors["prevten"])
.to include(match I18n.t("validations.household.prevten.internal_transfer", prevten: ""))
expect(record.errors["referral"])
.to include(match I18n.t("validations.household.referral.prevten_invalid", prevten: ""))
end
it "cannot be 4, 10, 13, 19, 23, 24, 25, 26, 28, 29" do
record.referral = 1
record.prevten = 4

Loading…
Cancel
Save