Browse Source

Referral can be internal for homeless (#561)

pull/619/head
baarkerlounger 3 years ago committed by baarkerlounger
parent
commit
a06a5f5896
  1. 10
      app/models/validations/household_validations.rb
  2. 14
      spec/models/validations/household_validations_spec.rb

10
app/models/validations/household_validations.rb

@ -111,16 +111,6 @@ module Validations::HouseholdValidations
end
def validate_referral(record)
if record.is_internal_transfer? && record.is_assessed_homeless?
record.errors.add :referral, I18n.t("validations.household.referral.assessed_homeless")
record.errors.add :homeless, I18n.t("validations.household.homeless.assessed.internal_transfer")
end
if record.is_internal_transfer? && record.is_other_homeless?
record.errors.add :referral, I18n.t("validations.household.referral.other_homeless")
record.errors.add :homeless, I18n.t("validations.household.homeless.other.internal_transfer")
end
if record.is_internal_transfer? && record.owning_organisation.provider_type == "PRP" && record.is_prevten_la_general_needs?
record.errors.add :referral, I18n.t("validations.household.referral.la_general_needs.internal_transfer")
record.errors.add :prevten, I18n.t("validations.household.prevten.la_general_needs.internal_transfer")

14
spec/models/validations/household_validations_spec.rb

@ -643,14 +643,12 @@ RSpec.describe Validations::HouseholdValidations do
describe "referral validations" do
context "when homelessness is assessed" do
it "cannot be internal transfer" do
it "can be internal transfer" do
record.homeless = 11
record.referral = 1
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match I18n.t("validations.household.referral.assessed_homeless"))
expect(record.errors["homeless"])
.to include(match I18n.t("validations.household.homeless.assessed.internal_transfer"))
expect(record.errors["referral"]).to be_empty
expect(record.errors["homeless"]).to be_empty
end
it "can be non internal transfer" do
@ -668,10 +666,8 @@ RSpec.describe Validations::HouseholdValidations do
record.referral = 1
record.homeless = 7
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match I18n.t("validations.household.referral.other_homeless"))
expect(record.errors["homeless"])
.to include(match I18n.t("validations.household.homeless.other.internal_transfer"))
expect(record.errors["referral"]).to be_empty
expect(record.errors["homeless"]).to be_empty
end
it "can be non internal transfer" do

Loading…
Cancel
Save