Browse Source

Update tests with referral_type

CLDC-3843-Lettings-household-situation-change-question-format
Manny Dinssa 6 days ago
parent
commit
b5e17e1b6d
  1. 25
      spec/models/validations/household_validations_spec.rb
  2. 1
      spec/models/validations/property_validations_spec.rb

25
spec/models/validations/household_validations_spec.rb

@ -129,33 +129,42 @@ RSpec.describe Validations::HouseholdValidations do
context "when referral is not internal transfer" do context "when referral is not internal transfer" do
it "cannot be permanently decanted from another property owned by this landlord" do it "cannot be permanently decanted from another property owned by this landlord" do
record.reason = 1 record.reason = 1
record.referral_type = 101
record.referral = 2 record.referral = 2
household_validator.validate_reason_for_leaving_last_settled_home(record) household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reason"]) expect(record.errors["reason"])
.to include(match(I18n.t("validations.lettings.household.reason.leaving_last_settled_home.not_internal_transfer"))) .to include(match(I18n.t("validations.lettings.household.reason.leaving_last_settled_home.not_internal_transfer")))
expect(record.errors["referral"]) expect(record.errors["referral"])
.to include(match(I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted"))) .to include(match(I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted")))
expect(record.errors["referral_type"])
.to include(match(I18n.t("validations.lettings.household.referral.leaving_last_settled_home.reason_permanently_decanted")))
end end
end end
context "when referral is internal transfer" do context "when referral is internal transfer" do
it "can be permanently decanted from another property owned by this landlord" do it "can be permanently decanted from another property owned by this landlord" do
record.reason = 1 record.reason = 1
record.referral_type = 103
record.referral = 1 record.referral = 1
household_validator.validate_reason_for_leaving_last_settled_home(record) household_validator.validate_reason_for_leaving_last_settled_home(record)
expect(record.errors["reason"]) expect(record.errors["reason"])
.to be_empty .to be_empty
expect(record.errors["referral"]) expect(record.errors["referral"])
.to be_empty .to be_empty
expect(record.errors["referral_type"])
.to be_empty
end end
it "cannot have a PRP as landlord and Housing situation before this letting cannot be LA general needs" do it "cannot have a PRP as landlord and Housing situation before this letting cannot be LA general needs" do
record.owning_organisation.provider_type = "PRP" record.owning_organisation.provider_type = "PRP"
record.prevten = 30 record.prevten = 30
record.referral_type = 103
record.referral = 1 record.referral = 1
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]) expect(record.errors["referral"])
.to include(match(I18n.t("validations.lettings.household.referral.la_general_needs.internal_transfer"))) .to include(match(I18n.t("validations.lettings.household.referral.la_general_needs.internal_transfer")))
expect(record.errors["referral_type"])
.to include(match(I18n.t("validations.lettings.household.referral.la_general_needs.internal_transfer")))
expect(record.errors["prevten"]) expect(record.errors["prevten"])
.to include(match(I18n.t("validations.lettings.household.prevten.la_general_needs.internal_transfer"))) .to include(match(I18n.t("validations.lettings.household.prevten.la_general_needs.internal_transfer")))
@ -163,6 +172,8 @@ RSpec.describe Validations::HouseholdValidations do
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]) expect(record.errors["referral"])
.to include(match(I18n.t("validations.lettings.household.referral.la_general_needs.internal_transfer"))) .to include(match(I18n.t("validations.lettings.household.referral.la_general_needs.internal_transfer")))
expect(record.errors["referral_type"])
.to include(match(I18n.t("validations.lettings.household.referral.la_general_needs.internal_transfer")))
expect(record.errors["prevten"]) expect(record.errors["prevten"])
.to include(match(I18n.t("validations.lettings.household.prevten.la_general_needs.internal_transfer"))) .to include(match(I18n.t("validations.lettings.household.prevten.la_general_needs.internal_transfer")))
end end
@ -603,37 +614,45 @@ RSpec.describe Validations::HouseholdValidations do
context "when homelessness is assessed" do context "when homelessness is assessed" do
it "can be internal transfer" do it "can be internal transfer" do
record.homeless = 11 record.homeless = 11
record.referral_type = 103
record.referral = 1 record.referral = 1
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
expect(record.errors["referral_type"]).to be_empty
expect(record.errors["homeless"]).to be_empty expect(record.errors["homeless"]).to be_empty
end end
it "can be non internal transfer" do it "can be non internal transfer" do
record.owning_organisation.provider_type = "PRP" record.owning_organisation.provider_type = "PRP"
record.homeless = 0 record.homeless = 0
record.referral_type = 102
record.referral = 3 record.referral = 3
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
expect(record.errors["referral_type"]).to be_empty
expect(record.errors["homeless"]).to be_empty expect(record.errors["homeless"]).to be_empty
end end
end end
context "when homelessness is other" do context "when homelessness is other" do
it "cannot be internal transfer" do it "cannot be internal transfer" do
record.referral_type = 103
record.referral = 1 record.referral = 1
record.homeless = 7 record.homeless = 7
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
expect(record.errors["referral_type"]).to be_empty
expect(record.errors["homeless"]).to be_empty expect(record.errors["homeless"]).to be_empty
end end
it "can be non internal transfer" do it "can be non internal transfer" do
record.owning_organisation.provider_type = "PRP" record.owning_organisation.provider_type = "PRP"
record.referral_type = 102
record.referral = 3 record.referral = 3
record.homeless = 1 record.homeless = 1
household_validator.validate_referral(record) household_validator.validate_referral(record)
expect(record.errors["referral"]).to be_empty expect(record.errors["referral"]).to be_empty
expect(record.errors["referral_type"]).to be_empty
expect(record.errors["homeless"]).to be_empty expect(record.errors["homeless"]).to be_empty
end end
end end
@ -715,6 +734,7 @@ RSpec.describe Validations::HouseholdValidations do
context "when the referral is internal transfer" do context "when the referral is internal transfer" do
it "prevten can be 9" do it "prevten can be 9" do
record.referral_type = 103
record.referral = 1 record.referral = 1
record.prevten = 9 record.prevten = 9
household_validator.validate_previous_housing_situation(record) household_validator.validate_previous_housing_situation(record)
@ -722,6 +742,8 @@ RSpec.describe Validations::HouseholdValidations do
.to be_empty .to be_empty
expect(record.errors["referral"]) expect(record.errors["referral"])
.to be_empty .to be_empty
expect(record.errors["referral_type"])
.to be_empty
end end
[ [
@ -740,6 +762,7 @@ RSpec.describe Validations::HouseholdValidations do
{ code: 29, label: "Prison or approved probation hostel" }, { code: 29, label: "Prison or approved probation hostel" },
].each do |prevten| ].each do |prevten|
it "prevten cannot be #{prevten[:code]}" do it "prevten cannot be #{prevten[:code]}" do
record.referral_type = 103
record.referral = 1 record.referral = 1
record.prevten = prevten[:code] record.prevten = prevten[:code]
household_validator.validate_previous_housing_situation(record) household_validator.validate_previous_housing_situation(record)
@ -748,6 +771,8 @@ RSpec.describe Validations::HouseholdValidations do
.to include(match I18n.t("validations.lettings.household.prevten.internal_transfer", prevten: label)) .to include(match I18n.t("validations.lettings.household.prevten.internal_transfer", prevten: label))
expect(record.errors["referral"]) expect(record.errors["referral"])
.to include(match I18n.t("validations.lettings.household.referral.prevten_invalid", prevten: "")) .to include(match I18n.t("validations.lettings.household.referral.prevten_invalid", prevten: ""))
expect(record.errors["referral_type"])
.to include(match I18n.t("validations.lettings.household.referral.prevten_invalid", prevten: ""))
end end
end end
end end

1
spec/models/validations/property_validations_spec.rb

@ -168,6 +168,7 @@ RSpec.describe Validations::PropertyValidations do
it "expects that the letting source can be a referral" do it "expects that the letting source can be a referral" do
log.prevten = 0 log.prevten = 0
record.referral_type = 101
log.referral = 2 log.referral = 2
property_validator.validate_rsnvac(log) property_validator.validate_rsnvac(log)
expect(log.errors["rsnvac"]).to be_empty expect(log.errors["rsnvac"]).to be_empty

Loading…
Cancel
Save