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

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
log.prevten = 0
record.referral_type = 101
log.referral = 2
property_validator.validate_rsnvac(log)
expect(log.errors["rsnvac"]).to be_empty

Loading…
Cancel
Save