Browse Source

CLDC-3384 referral tests and inconsistencies (#2370)

* CLDC-3156: Update 2024 referral options

* CLDC-3156: Add tests for referral question

* CLDC-3156: Update other referral questions

* CLDC-3384: Referral question inconsistencies and tests

* feat: remove option 4 from 24/25 referral

* feat: update tests

---------

Co-authored-by: natdeanlewissoftwire <nat.dean-lewis@softwire.com>
pull/2383/head
Robert Sullivan 8 months ago committed by GitHub
parent
commit
c309a4760b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      app/models/form/lettings/questions/referral_prp.rb
  2. 10
      app/models/form/lettings/questions/referral_supported_housing.rb
  3. 4
      app/models/validations/household_validations.rb
  4. 2
      config/locales/en.yml
  5. 104
      spec/models/form/lettings/questions/referral_prp_spec.rb
  6. 105
      spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb
  7. 101
      spec/models/form/lettings/questions/referral_supported_housing_spec.rb
  8. 18
      spec/models/validations/household_validations_spec.rb

7
app/models/form/lettings/questions/referral_prp.rb

@ -18,14 +18,11 @@ class Form::Lettings::Questions::ReferralPrp < ::Form::Question
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", "hint" => "Where the tenant has moved to another social property owned by the same landlord.",
}, },
"2" => { "2" => {
"value" => "Tenant applied directly (no nomination)", "value" => "Tenant applied directly (no referral or nomination)",
}, },
"3" => { "3" => {
"value" => "Nominated by a local housing authority", "value" => "Nominated by a local housing authority",
}, },
"4" => {
"value" => "Referred by local authority housing department",
},
"8" => { "8" => {
"value" => "Re-located through official housing mobility scheme", "value" => "Re-located through official housing mobility scheme",
}, },
@ -64,7 +61,7 @@ class Form::Lettings::Questions::ReferralPrp < ::Form::Question
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", "hint" => "Where the tenant has moved to another social property owned by the same landlord.",
}, },
"2" => { "2" => {
"value" => "Tenant applied directly (no nomination)", "value" => "Tenant applied directly (no referral or nomination)",
}, },
"3" => { "3" => {
"value" => "Nominated by a local housing authority", "value" => "Nominated by a local housing authority",

10
app/models/form/lettings/questions/referral_supported_housing.rb

@ -18,10 +18,7 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", "hint" => "Where the tenant has moved to another social property owned by the same landlord.",
}, },
"2" => { "2" => {
"value" => "Tenant applied directly (no referral)", "value" => "Tenant applied directly (no referral or nomination)",
},
"3" => {
"value" => "Nominated by a local housing authority",
}, },
"8" => { "8" => {
"value" => "Re-located through official housing mobility scheme", "value" => "Re-located through official housing mobility scheme",
@ -61,10 +58,7 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question
"hint" => "Where the tenant has moved to another social property owned by the same landlord.", "hint" => "Where the tenant has moved to another social property owned by the same landlord.",
}, },
"2" => { "2" => {
"value" => "Tenant applied directly (no referral)", "value" => "Tenant applied directly (no referral or nomination)",
},
"3" => {
"value" => "Nominated by a local housing authority",
}, },
"8" => { "8" => {
"value" => "Re-located through official housing mobility scheme", "value" => "Re-located through official housing mobility scheme",

4
app/models/validations/household_validations.rb

@ -178,10 +178,6 @@ module Validations::HouseholdValidations
record.errors.add :prevten, :internal_transfer_fixed_or_lifetime, message: I18n.t("validations.household.prevten.la_general_needs.internal_transfer") record.errors.add :prevten, :internal_transfer_fixed_or_lifetime, message: I18n.t("validations.household.prevten.la_general_needs.internal_transfer")
record.errors.add :referral, :internal_transfer_fixed_or_lifetime, message: I18n.t("validations.household.referral.la_general_needs.internal_transfer") record.errors.add :referral, :internal_transfer_fixed_or_lifetime, message: I18n.t("validations.household.referral.la_general_needs.internal_transfer")
end end
if record.owning_organisation.provider_type == "LA" && record.local_housing_referral?
record.errors.add :referral, I18n.t("validations.household.referral.prp.local_housing_referral")
end
end end
def validate_prevloc(record) def validate_prevloc(record)

2
config/locales/en.yml

@ -533,8 +533,6 @@ en:
la_general_needs: la_general_needs:
internal_transfer: "Answer cannot be internal transfer as it’s the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting" internal_transfer: "Answer cannot be internal transfer as it’s the same landlord on the tenancy agreement and the household had either a fixed-term or lifetime local authority general needs tenancy immediately before this letting"
prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log" prp_referred_by_la: "The source of the referral cannot be referred by local authority housing department for a general needs log"
prp:
local_housing_referral: "Answer cannot be ‘nominated by a local housing authority’ as a local authority is on the tenancy agreement"
homeless: homeless:
assessed: assessed:
internal_transfer: "Answer cannot be 'assessed as homeless' as this tenancy is an internal transfer" internal_transfer: "Answer cannot be 'assessed as homeless' as this tenancy is an internal transfer"

104
spec/models/form/lettings/questions/referral_prp_spec.rb

@ -0,0 +1,104 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralPrp, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("referral")
end
it "has the correct header" do
expect(question.header).to eq("What was the source of referral for this letting?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Source of referral for letting")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(0)
end
it "has the correct hint" do
expect(question.hint_text).to eq("You told us that the needs type is general needs. We have removed some options because of this.")
end
it "is not marked as derived" do
expect(question).not_to be_derived(nil)
end
context "with 2023/24 form" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" },
"3" => { "value" => "Nominated by a local housing authority" },
"4" => { "value" => "Referred by local authority housing department" },
"8" => { "value" => "Re-located through official housing mobility scheme" },
"10" => { "value" => "Other social landlord" },
"9" => { "value" => "Community learning disability team" },
"14" => { "value" => "Community mental health team" },
"15" => { "value" => "Health service" },
"12" => { "value" => "Police, probation or prison" },
"7" => { "value" => "Voluntary agency" },
"13" => { "value" => "Youth offending team" },
"17" => { "value" => "Children’s Social Care" },
"16" => { "value" => "Other" },
})
end
it "has the correct question number" do
expect(question.question_number).to eq(85)
end
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" },
"3" => { "value" => "Nominated by a local housing authority" },
"8" => { "value" => "Re-located through official housing mobility scheme" },
"10" => { "value" => "Other social landlord" },
"9" => { "value" => "Community learning disability team" },
"14" => { "value" => "Community mental health team" },
"15" => { "value" => "Health service" },
"18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" },
"19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" },
"7" => { "value" => "Voluntary agency" },
"17" => { "value" => "Children’s Social Care" },
"16" => { "value" => "Other" },
})
end
it "has the correct question number" do
expect(question.question_number).to eq(84)
end
end
end

105
spec/models/form/lettings/questions/referral_supported_housing_prp_spec.rb

@ -0,0 +1,105 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralSupportedHousingPrp, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("referral")
end
it "has the correct header" do
expect(question.header).to eq("What was the source of referral for this letting?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Source of referral for letting")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(0)
end
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
it "is not marked as derived" do
expect(question).not_to be_derived(nil)
end
context "with 2023/24 form" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" },
"3" => { "value" => "Nominated by a local housing authority" },
"4" => { "value" => "Referred by local authority housing department" },
"8" => { "value" => "Re-located through official housing mobility scheme" },
"10" => { "value" => "Other social landlord" },
"9" => { "value" => "Community learning disability team" },
"14" => { "value" => "Community mental health team" },
"15" => { "value" => "Health service" },
"12" => { "value" => "Police, probation or prison" },
"7" => { "value" => "Voluntary agency" },
"13" => { "value" => "Youth offending team" },
"17" => { "value" => "Children’s Social Care" },
"16" => { "value" => "Other" },
})
end
it "has the correct question number" do
expect(question.question_number).to eq(85)
end
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" },
"3" => { "value" => "Nominated by a local housing authority" },
"4" => { "value" => "Referred by local authority housing department" },
"8" => { "value" => "Re-located through official housing mobility scheme" },
"10" => { "value" => "Other social landlord" },
"9" => { "value" => "Community learning disability team" },
"14" => { "value" => "Community mental health team" },
"15" => { "value" => "Health service" },
"18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" },
"19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" },
"7" => { "value" => "Voluntary agency" },
"17" => { "value" => "Children’s Social Care" },
"16" => { "value" => "Other" },
})
end
it "has the correct question number" do
expect(question.question_number).to eq(84)
end
end
end

101
spec/models/form/lettings/questions/referral_supported_housing_spec.rb

@ -0,0 +1,101 @@
require "rails_helper"
RSpec.describe Form::Lettings::Questions::ReferralSupportedHousing, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(false)
allow(page).to receive(:subsection).and_return(subsection)
allow(subsection).to receive(:form).and_return(form)
end
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("referral")
end
it "has the correct header" do
expect(question.header).to eq("What was the source of referral for this letting?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Source of referral for letting")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "has the correct check_answers_card_number" do
expect(question.check_answers_card_number).to eq(0)
end
it "has the correct hint" do
expect(question.hint_text).to eq("You told us that you are a local authority. We have removed some options because of this.")
end
it "is not marked as derived" do
expect(question).not_to be_derived(nil)
end
context "with 2023/24 form" do
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" },
"8" => { "value" => "Re-located through official housing mobility scheme" },
"10" => { "value" => "Other social landlord" },
"9" => { "value" => "Community learning disability team" },
"14" => { "value" => "Community mental health team" },
"15" => { "value" => "Health service" },
"12" => { "value" => "Police, probation or prison" },
"7" => { "value" => "Voluntary agency" },
"13" => { "value" => "Youth offending team" },
"17" => { "value" => "Children’s Social Care" },
"16" => { "value" => "Other" },
})
end
it "has the correct question number" do
expect(question.question_number).to eq(85)
end
end
context "with 2024/25 form" do
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
before do
allow(form).to receive(:start_year_after_2024?).and_return(true)
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Internal transfer", "hint" => "Where the tenant has moved to another social property owned by the same landlord." },
"2" => { "value" => "Tenant applied directly (no referral or nomination)" },
"8" => { "value" => "Re-located through official housing mobility scheme" },
"10" => { "value" => "Other social landlord" },
"9" => { "value" => "Community learning disability team" },
"14" => { "value" => "Community mental health team" },
"15" => { "value" => "Health service" },
"18" => { "value" => "Police, probation, prison or youth offending team – tenant had custodial sentence" },
"19" => { "value" => "Police, probation, prison or youth offending team – no custodial sentence" },
"7" => { "value" => "Voluntary agency" },
"17" => { "value" => "Children’s Social Care" },
"16" => { "value" => "Other" },
})
end
it "has the correct question number" do
expect(question.question_number).to eq(84)
end
end
end

18
spec/models/validations/household_validations_spec.rb

@ -177,24 +177,6 @@ RSpec.describe Validations::HouseholdValidations do
.to include(match(I18n.t("validations.household.prevten.la_general_needs.internal_transfer"))) .to include(match(I18n.t("validations.household.prevten.la_general_needs.internal_transfer")))
end end
end end
context "when referral is nominated by a local housing authority" do
it "cannot have a local authority" do
record.owning_organisation.provider_type = "LA"
record.referral = 3
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to include(match(I18n.t("validations.household.referral.prp.local_housing_referral")))
end
it "can have a private registered provider" do
record.owning_organisation.provider_type = "PRP"
record.referral = 3
household_validator.validate_referral(record)
expect(record.errors["referral"])
.to be_empty
end
end
end end
describe "armed forces validations" do describe "armed forces validations" do

Loading…
Cancel
Save