Browse Source
* CLDC-4151: Note deprecations of existing referral questions * CLDC-4151: Add new cols to lettings log model * CLDC-4151: Add new referrals questions * CLDC-4151: Remove referral value check * CLDC-4151: Add new fields to bulk upload use new fields as presented in bulk upload * CLDC-4151: Update tests also add bulk upload file to test with * CLDC-4151: Ignore tests failing for later tickets * fixup! CLDC-4151: Add new referrals questions start q nums from 2026 * CLDC-4151: Add model tests for new questions * fixup! CLDC-4151: Add new fields to bulk upload export old_visible_id set MAX_COLUMNS correctly check .prp? for prp cols * fixup! CLDC-4151: Update tests clarify tests that may update * fixup! CLDC-4151: Add new fields to bulk upload handle the old_visible_id not existing use override org ID only for the output owning ID. it's only passed as eg ORG1 * CLDC-4151: Add new questions to log factory * fixup! CLDC-4151: Add new fields to bulk upload leave field_131 validations till later * CLDC-4188: Add LA flow splits the referral_register question and pages into two, as its not easy to have the answers be dependent if the owning organisation changes type, reset the referral register question. the other questions do not need to be reset as they are no longer routed to * CLDC-4188: Infer referral_register for renewals needs a new dependencies array for 2026 this handles inferring as well as clearing inferred answers if the prior answer changes * CLDC-4188: Add validation between prevten and referral_register block two other validations from previous years * CLDC-4188: Update tests * CLDC-4188: Ignore tests failing for future tickets * CLDC-4188: Update existing tests needed as should_reset_referral_register? calls a .find() * fixup! CLDC-4188: Add validation between prevten and referral_register use .prp? improve grammar * fixup! CLDC-4188: Infer referral_register for renewals extract dependencies to common list * fixup! CLDC-4188: Update tests use before and context blocks better * fixup! CLDC-4188: Update tests lint * fixup! CLDC-4188: Update tests remove unneeded referral_type set * CLDC-4189: Add PRP flow * CLDC-4189: Update validation between prevten and referral_register * CLDC-4189: Add tests * fixup! CLDC-4189: Add PRP flow fix typo Co-authored-by: Oscar Richardson <116292912+oscar-richardson-softwire@users.noreply.github.com> * fixup! CLDC-4189: Add tests fix typo * fixup! CLDC-4189: Add tests fix missing cases in page specs use a loop and before blocks for household validation tests * CLDC-4189: Ensure log is not classed as generan needs if prevten isnt answered * fixup! CLDC-4189: Add tests add cases for other internal transfer flow * CLDC-4151: Add final question numbers * fixup! CLDC-4189: Update validation between prevten and referral_register include new code 40 from CLDC-4149 * fixup! CLDC-4151: Add final question numbers reinstate fallback * CLDC-4190: Q84 Referral BU validations (#3155) * CLDC-4151: Note deprecations of existing referral questions * CLDC-4151: Add new cols to lettings log model * CLDC-4151: Add new referrals questions * CLDC-4151: Remove referral value check * CLDC-4151: Add new fields to bulk upload use new fields as presented in bulk upload * CLDC-4151: Update tests also add bulk upload file to test with * CLDC-4151: Ignore tests failing for later tickets * fixup! CLDC-4151: Add new referrals questions start q nums from 2026 * CLDC-4151: Add model tests for new questions * fixup! CLDC-4151: Add new fields to bulk upload export old_visible_id set MAX_COLUMNS correctly check .prp? for prp cols * fixup! CLDC-4151: Update tests clarify tests that may update * fixup! CLDC-4151: Add new fields to bulk upload handle the old_visible_id not existing use override org ID only for the output owning ID. it's only passed as eg ORG1 * CLDC-4151: Add new questions to log factory * fixup! CLDC-4151: Add new fields to bulk upload leave field_131 validations till later * CLDC-4188: Add LA flow splits the referral_register question and pages into two, as its not easy to have the answers be dependent if the owning organisation changes type, reset the referral register question. the other questions do not need to be reset as they are no longer routed to * CLDC-4188: Infer referral_register for renewals needs a new dependencies array for 2026 this handles inferring as well as clearing inferred answers if the prior answer changes * CLDC-4188: Add validation between prevten and referral_register block two other validations from previous years * CLDC-4188: Update tests * CLDC-4188: Ignore tests failing for future tickets * CLDC-4188: Update existing tests needed as should_reset_referral_register? calls a .find() * fixup! CLDC-4188: Add validation between prevten and referral_register use .prp? improve grammar * fixup! CLDC-4188: Infer referral_register for renewals extract dependencies to common list * fixup! CLDC-4188: Update tests use before and context blocks better * fixup! CLDC-4188: Update tests lint * fixup! CLDC-4188: Update tests remove unneeded referral_type set * CLDC-4189: Add PRP flow * CLDC-4189: Update validation between prevten and referral_register * CLDC-4189: Add tests * fixup! CLDC-4189: Add PRP flow fix typo Co-authored-by: Oscar Richardson <116292912+oscar-richardson-softwire@users.noreply.github.com> * fixup! CLDC-4189: Add tests fix typo * fixup! CLDC-4189: Add tests fix missing cases in page specs use a loop and before blocks for household validation tests * CLDC-4189: Ensure log is not classed as generan needs if prevten isnt answered * fixup! CLDC-4189: Add tests add cases for other internal transfer flow * CLDC-4190: Invalidate all referral fields if any are wrong * CLDC-4190: Remove other validations on referral fields * CLDC-4190: Ignore referral validation if BU is renewal * CLDC-4190: Add tests * fixup! CLDC-4190: Invalidate all referral fields if any are wrong add punctuation to comment name validation fields better * fixup! CLDC-4190: Add tests make test names clearer * CLDC-4190: Final field fixes --------- Co-authored-by: Oscar Richardson <116292912+oscar-richardson-softwire@users.noreply.github.com> * CLDC-4191: Q84 Referral CSV and XML export (#3157) * CLDC-4151: Note deprecations of existing referral questions * CLDC-4151: Add new cols to lettings log model * CLDC-4151: Add new referrals questions * CLDC-4151: Remove referral value check * CLDC-4151: Add new fields to bulk upload use new fields as presented in bulk upload * CLDC-4151: Update tests also add bulk upload file to test with * CLDC-4151: Ignore tests failing for later tickets * fixup! CLDC-4151: Add new referrals questions start q nums from 2026 * CLDC-4151: Add model tests for new questions * fixup! CLDC-4151: Add new fields to bulk upload export old_visible_id set MAX_COLUMNS correctly check .prp? for prp cols * fixup! CLDC-4151: Update tests clarify tests that may update * fixup! CLDC-4151: Add new fields to bulk upload handle the old_visible_id not existing use override org ID only for the output owning ID. it's only passed as eg ORG1 * CLDC-4151: Add new questions to log factory * fixup! CLDC-4151: Add new fields to bulk upload leave field_131 validations till later * CLDC-4188: Add LA flow splits the referral_register question and pages into two, as its not easy to have the answers be dependent if the owning organisation changes type, reset the referral register question. the other questions do not need to be reset as they are no longer routed to * CLDC-4188: Infer referral_register for renewals needs a new dependencies array for 2026 this handles inferring as well as clearing inferred answers if the prior answer changes * CLDC-4188: Add validation between prevten and referral_register block two other validations from previous years * CLDC-4188: Update tests * CLDC-4188: Ignore tests failing for future tickets * CLDC-4188: Update existing tests needed as should_reset_referral_register? calls a .find() * fixup! CLDC-4188: Add validation between prevten and referral_register use .prp? improve grammar * fixup! CLDC-4188: Infer referral_register for renewals extract dependencies to common list * fixup! CLDC-4188: Update tests use before and context blocks better * fixup! CLDC-4188: Update tests lint * fixup! CLDC-4188: Update tests remove unneeded referral_type set * CLDC-4189: Add PRP flow * CLDC-4189: Update validation between prevten and referral_register * CLDC-4189: Add tests * fixup! CLDC-4189: Add PRP flow fix typo Co-authored-by: Oscar Richardson <116292912+oscar-richardson-softwire@users.noreply.github.com> * fixup! CLDC-4189: Add tests fix typo * fixup! CLDC-4189: Add tests fix missing cases in page specs use a loop and before blocks for household validation tests * CLDC-4189: Ensure log is not classed as generan needs if prevten isnt answered * fixup! CLDC-4189: Add tests add cases for other internal transfer flow * CLDC-4190: Invalidate all referral fields if any are wrong * CLDC-4190: Remove other validations on referral fields * CLDC-4190: Ignore referral validation if BU is renewal * CLDC-4190: Add tests * fixup! CLDC-4190: Invalidate all referral fields if any are wrong add punctuation to comment name validation fields better * fixup! CLDC-4190: Add tests make test names clearer * CLDC-4191: Update CSV export tests the export happens by default, no changes needed here * CLDC-4191: Add new referral fields to 2026 exports remove old referral fields from 2026 exports ensure new referral fields don't show in pre 2026 exports * CLDC-4190: Final field fixes --------- Co-authored-by: Oscar Richardson <116292912+oscar-richardson-softwire@users.noreply.github.com> --------- Co-authored-by: Oscar Richardson <116292912+oscar-richardson-softwire@users.noreply.github.com>pull/3180/head^2
71 changed files with 1833 additions and 179 deletions
@ -0,0 +1,15 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Pages::ReferralNomsHr < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_noms_hr" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralNoms.new(nil, nil, self, 7)] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user) |
||||
log.owning_organisation&.prp? && !log.is_renewal? && log.referral_is_from_housing_register? |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Pages::ReferralNomsLaHr < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_noms_la_hr" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralNoms.new(nil, nil, self, 6)] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user) |
||||
log.owning_organisation&.prp? && !log.is_renewal? && log.referral_is_from_local_authority_housing_register? |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Pages::ReferralOrgDirectlyReferred < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_org_directly_referred" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralOrg.new(nil, nil, self, 7)] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user) |
||||
log.owning_organisation&.prp? && !log.is_renewal? && log.referral_is_directly_referred? |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Pages::ReferralOrgNominated < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_org_nominated" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralOrg.new(nil, nil, self, 1)] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user) |
||||
log.owning_organisation&.prp? && !log.is_renewal? && log.referral_is_nominated_by_local_authority? |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Pages::ReferralRegisterLa < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_register_la" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralRegister.new(nil, nil, self, :la)] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user) |
||||
log.owning_organisation&.la? && !log.is_renewal? |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Pages::ReferralRegisterPrp < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "referral_register_prp" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [Form::Lettings::Questions::ReferralRegister.new(nil, nil, self, :prp)] |
||||
end |
||||
|
||||
def routed_to?(log, _current_user) |
||||
log.owning_organisation&.prp? && !log.is_renewal? |
||||
end |
||||
end |
||||
@ -0,0 +1,49 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Questions::ReferralNoms < ::Form::Question |
||||
def initialize(id, hsh, page, referral_register) |
||||
super(id, hsh, page) |
||||
@id = "referral_noms" |
||||
@copy_key = "lettings.household_situation.referral.noms" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) |
||||
@referral_register = referral_register |
||||
end |
||||
|
||||
def answer_options |
||||
case @referral_register |
||||
when 6 |
||||
{ |
||||
"1" => { |
||||
"value" => "Nominated by a local authority to a PRP", |
||||
}, |
||||
"2" => { |
||||
"value" => "Supported housing only - referred by a local authority to a PRP", |
||||
}, |
||||
"3" => { |
||||
"value" => "Internal transfer from another property owned by the same PRP landlord - for existing social tenants only", |
||||
}, |
||||
"4" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze |
||||
when 7 |
||||
{ |
||||
"5" => { |
||||
"value" => "Internal transfer from another property owned by the same PRP landlord - for existing social tenants only", |
||||
}, |
||||
"6" => { |
||||
"value" => " A different PRP landlord - for existing social tenants only", |
||||
}, |
||||
"7" => { |
||||
"value" => "Directly referred by a third party", |
||||
}, |
||||
"8" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze |
||||
end |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 92 }.freeze |
||||
end |
||||
@ -0,0 +1,85 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Questions::ReferralOrg < ::Form::Question |
||||
def initialize(id, hsh, page, referral_noms) |
||||
super(id, hsh, page) |
||||
@id = "referral_org" |
||||
@copy_key = "lettings.household_situation.referral.org" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) |
||||
@referral_noms = referral_noms |
||||
end |
||||
|
||||
def answer_options |
||||
case @referral_noms |
||||
when 1 |
||||
{ |
||||
"1" => { |
||||
"value" => "Referred to LA by health service", |
||||
}, |
||||
"2" => { |
||||
"value" => "Referred to LA by community learning disability team", |
||||
}, |
||||
"3" => { |
||||
"value" => "Referred to LA by community mental health team", |
||||
}, |
||||
"4" => { |
||||
"value" => "Referred to LA by adult social services", |
||||
}, |
||||
"5" => { |
||||
"value" => "Referred to LA by children's social care", |
||||
}, |
||||
"6" => { |
||||
"value" => "Referred to LA by police, probation, prison or youth offending team following a custodial sentence", |
||||
}, |
||||
"7" => { |
||||
"value" => "Referred to LA by police, probation, prison or youth offending team without a custodial sentence", |
||||
}, |
||||
"8" => { |
||||
"value" => "Referred to LA by a voluntary agency", |
||||
}, |
||||
"9" => { |
||||
"value" => "Other referral", |
||||
}, |
||||
"10" => { |
||||
"value" => "Don't know", |
||||
}, |
||||
}.freeze |
||||
when 7 |
||||
{ |
||||
"11" => { |
||||
"value" => "Health service", |
||||
}, |
||||
"12" => { |
||||
"value" => "Community learning disability team", |
||||
}, |
||||
"13" => { |
||||
"value" => "Community mental health team", |
||||
}, |
||||
"14" => { |
||||
"value" => "Adult social services", |
||||
}, |
||||
"15" => { |
||||
"value" => "Children's social care", |
||||
}, |
||||
"16" => { |
||||
"value" => "Police, probation, prison or youth offending team following a custodial sentence", |
||||
}, |
||||
"17" => { |
||||
"value" => "Police, probation, prison or youth offending team without a custodial sentence", |
||||
}, |
||||
"18" => { |
||||
"value" => "Voluntary agency", |
||||
}, |
||||
"19" => { |
||||
"value" => "Other third party", |
||||
}, |
||||
"20" => { |
||||
"value" => "Don't know", |
||||
}, |
||||
}.freeze |
||||
end |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 92 }.freeze |
||||
end |
||||
@ -0,0 +1,56 @@
|
||||
# added in 2026 |
||||
class Form::Lettings::Questions::ReferralRegister < ::Form::Question |
||||
def initialize(id, hsh, page, provider_type) |
||||
super(id, hsh, page) |
||||
@id = "referral_register" |
||||
@copy_key = "lettings.household_situation.referral.register" |
||||
@type = "radio" |
||||
@check_answers_card_number = 0 |
||||
@provider_type = provider_type |
||||
@question_number = get_question_number_from_hash(QUESTION_NUMBER_FROM_YEAR) |
||||
@question_number += 1 if @provider_type == :prp |
||||
end |
||||
|
||||
def answer_options |
||||
if @provider_type == :la |
||||
{ |
||||
"1" => { |
||||
"value" => "Renewal to the same tenant in the same property", |
||||
}, |
||||
"2" => { |
||||
"value" => "Internal transfer from another property owned by the same local authority - for existing social tenants only", |
||||
}, |
||||
"3" => { |
||||
"value" => "From a housing register (waiting list)", |
||||
}, |
||||
"4" => { |
||||
"value" => "Tenant applied directly (not via a nomination or housing register)", |
||||
}, |
||||
}.freeze |
||||
else |
||||
{ |
||||
"5" => { |
||||
"value" => "Renewal to the same tenant in the same property", |
||||
}, |
||||
"6" => { |
||||
"value" => "From a local authority housing register (waiting list) or a register with local authority involvement", |
||||
}, |
||||
"7" => { |
||||
"value" => "From a housing register (waiting list) with no local authority involvement", |
||||
}, |
||||
"8" => { |
||||
"value" => "Tenant applied directly (not via a nomination or waiting list)", |
||||
}, |
||||
"9" => { |
||||
"value" => "Don't know", |
||||
}, |
||||
}.freeze |
||||
end |
||||
end |
||||
|
||||
def derived?(log) |
||||
log.is_renewal? |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2026 => 91 }.freeze |
||||
end |
||||
@ -0,0 +1,9 @@
|
||||
class Add2026ReferralFields < ActiveRecord::Migration[7.2] |
||||
def change |
||||
change_table :lettings_logs, bulk: true do |t| |
||||
t.integer :referral_register |
||||
t.integer :referral_noms |
||||
t.integer :referral_org |
||||
end |
||||
end |
||||
end |
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
Can't render this file because it has a wrong number of fields in line 18.
|
@ -0,0 +1,79 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::ReferralNomsHr, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form:) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:prp?) { nil } |
||||
let(:organisation) { instance_double(Organisation, prp?: prp?) } |
||||
let(:is_renewal?) { nil } |
||||
let(:referral_is_from_housing_register?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?, owning_organisation: organisation, referral_is_from_housing_register?: referral_is_from_housing_register?) } |
||||
|
||||
before do |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[referral_noms]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("referral_noms_hr") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
context "and log owning organisation is not prp" do |
||||
let(:prp?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is prp" do |
||||
let(:prp?) { true } |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
context "and log referral is not from housing register" do |
||||
let(:referral_is_from_housing_register?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log referral is from housing register" do |
||||
let(:referral_is_from_housing_register?) { true } |
||||
|
||||
it "is routed to" do |
||||
expect(page.routed_to?(log, nil)).to be true |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,79 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::ReferralNomsLaHr, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form:) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:prp?) { nil } |
||||
let(:organisation) { instance_double(Organisation, prp?: prp?) } |
||||
let(:is_renewal?) { nil } |
||||
let(:referral_is_from_local_authority_housing_register?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?, owning_organisation: organisation, referral_is_from_local_authority_housing_register?: referral_is_from_local_authority_housing_register?) } |
||||
|
||||
before do |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[referral_noms]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("referral_noms_la_hr") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
context "and log owning organisation is not prp" do |
||||
let(:prp?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is prp" do |
||||
let(:prp?) { true } |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
context "and log referral is not from local authority housing register" do |
||||
let(:referral_is_from_local_authority_housing_register?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log referral is from local authority housing register" do |
||||
let(:referral_is_from_local_authority_housing_register?) { true } |
||||
|
||||
it "is routed to" do |
||||
expect(page.routed_to?(log, nil)).to be true |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,79 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::ReferralOrgDirectlyReferred, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form:) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:prp?) { nil } |
||||
let(:organisation) { instance_double(Organisation, prp?: prp?) } |
||||
let(:is_renewal?) { nil } |
||||
let(:referral_is_directly_referred?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?, owning_organisation: organisation, referral_is_directly_referred?: referral_is_directly_referred?) } |
||||
|
||||
before do |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[referral_org]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("referral_org_directly_referred") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
context "and log owning organisation is not prp" do |
||||
let(:prp?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is prp" do |
||||
let(:prp?) { true } |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
context "and log referral is not nominated by local authority" do |
||||
let(:referral_is_directly_referred?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log referral is nominated by local authority" do |
||||
let(:referral_is_directly_referred?) { true } |
||||
|
||||
it "is routed to" do |
||||
expect(page.routed_to?(log, nil)).to be true |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,79 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::ReferralOrgNominated, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form:) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:prp?) { nil } |
||||
let(:organisation) { instance_double(Organisation, prp?: prp?) } |
||||
let(:is_renewal?) { nil } |
||||
let(:referral_is_nominated_by_local_authority?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?, owning_organisation: organisation, referral_is_nominated_by_local_authority?: referral_is_nominated_by_local_authority?) } |
||||
|
||||
before do |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[referral_org]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("referral_org_nominated") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
context "and log owning organisation is not prp" do |
||||
let(:prp?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is prp" do |
||||
let(:prp?) { true } |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
context "and log referral is not nominated by local authority" do |
||||
let(:referral_is_nominated_by_local_authority?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log referral is nominated by local authority" do |
||||
let(:referral_is_nominated_by_local_authority?) { true } |
||||
|
||||
it "is routed to" do |
||||
expect(page.routed_to?(log, nil)).to be true |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,78 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::ReferralRegisterLa, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form:) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:la?) { nil } |
||||
let(:organisation) { instance_double(Organisation, la?: la?) } |
||||
let(:is_renewal?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?, owning_organisation: organisation) } |
||||
|
||||
before do |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[referral_register]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("referral_register_la") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
context "and log owning organisation is la" do |
||||
let(:la?) { true } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is not an la" do |
||||
let(:la?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "when log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
context "and log owning organisation is la" do |
||||
let(:la?) { true } |
||||
|
||||
it "is routed to" do |
||||
expect(page.routed_to?(log, nil)).to be true |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is not an la" do |
||||
let(:la?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,78 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Pages::ReferralRegisterPrp, type: :model do |
||||
subject(:page) { described_class.new(page_id, page_definition, subsection) } |
||||
|
||||
let(:page_id) { nil } |
||||
let(:page_definition) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection, form:) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:prp?) { nil } |
||||
let(:organisation) { instance_double(Organisation, prp?: prp?) } |
||||
let(:is_renewal?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?, owning_organisation: organisation) } |
||||
|
||||
before do |
||||
allow(subsection).to receive(:form).and_return(form) |
||||
end |
||||
|
||||
it "has correct subsection" do |
||||
expect(page.subsection).to eq(subsection) |
||||
end |
||||
|
||||
it "has correct questions" do |
||||
expect(page.questions.map(&:id)).to eq(%w[referral_register]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("referral_register_prp") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(page.depends_on).to be nil |
||||
end |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
context "and log owning organisation is prp" do |
||||
let(:prp?) { true } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is not prp" do |
||||
let(:prp?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
end |
||||
|
||||
context "when log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
context "and log owning organisation is prp" do |
||||
let(:prp?) { true } |
||||
|
||||
it "is routed to" do |
||||
expect(page.routed_to?(log, nil)).to be true |
||||
end |
||||
end |
||||
|
||||
context "and log owning organisation is not prp" do |
||||
let(:prp?) { false } |
||||
|
||||
it "is not routed to" do |
||||
expect(page.routed_to?(log, nil)).to be false |
||||
end |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,83 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::ReferralNoms, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, referral_register) } |
||||
|
||||
let(:question_id) { nil } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page) } |
||||
let(:referral_register) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
|
||||
before do |
||||
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_noms") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(nil)).to be false |
||||
end |
||||
|
||||
context "when referral_register is 6" do |
||||
let(:referral_register) { 6 } |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"1" => { |
||||
"value" => "Nominated by a local authority to a PRP", |
||||
}, |
||||
"2" => { |
||||
"value" => "Supported housing only - referred by a local authority to a PRP", |
||||
}, |
||||
"3" => { |
||||
"value" => "Internal transfer from another property owned by the same PRP landlord - for existing social tenants only", |
||||
}, |
||||
"4" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze, |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "when referral_register is 7" do |
||||
let(:referral_register) { 7 } |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"5" => { |
||||
"value" => "Internal transfer from another property owned by the same PRP landlord - for existing social tenants only", |
||||
}, |
||||
"6" => { |
||||
"value" => " A different PRP landlord - for existing social tenants only", |
||||
}, |
||||
"7" => { |
||||
"value" => "Directly referred by a third party", |
||||
}, |
||||
"8" => { |
||||
"value" => "Other", |
||||
}, |
||||
}.freeze, |
||||
) |
||||
end |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(question.question_number).to eq(92) |
||||
end |
||||
end |
||||
@ -0,0 +1,119 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::ReferralOrg, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, referral_noms) } |
||||
|
||||
let(:question_id) { nil } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page) } |
||||
let(:referral_noms) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
|
||||
before do |
||||
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_org") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(nil)).to be false |
||||
end |
||||
|
||||
context "when referral_noms is 1" do |
||||
let(:referral_noms) { 1 } |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"1" => { |
||||
"value" => "Referred to LA by health service", |
||||
}, |
||||
"2" => { |
||||
"value" => "Referred to LA by community learning disability team", |
||||
}, |
||||
"3" => { |
||||
"value" => "Referred to LA by community mental health team", |
||||
}, |
||||
"4" => { |
||||
"value" => "Referred to LA by adult social services", |
||||
}, |
||||
"5" => { |
||||
"value" => "Referred to LA by children's social care", |
||||
}, |
||||
"6" => { |
||||
"value" => "Referred to LA by police, probation, prison or youth offending team following a custodial sentence", |
||||
}, |
||||
"7" => { |
||||
"value" => "Referred to LA by police, probation, prison or youth offending team without a custodial sentence", |
||||
}, |
||||
"8" => { |
||||
"value" => "Referred to LA by a voluntary agency", |
||||
}, |
||||
"9" => { |
||||
"value" => "Other referral", |
||||
}, |
||||
"10" => { |
||||
"value" => "Don't know", |
||||
}, |
||||
}.freeze, |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "when referral_noms is 7" do |
||||
let(:referral_noms) { 7 } |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"11" => { |
||||
"value" => "Health service", |
||||
}, |
||||
"12" => { |
||||
"value" => "Community learning disability team", |
||||
}, |
||||
"13" => { |
||||
"value" => "Community mental health team", |
||||
}, |
||||
"14" => { |
||||
"value" => "Adult social services", |
||||
}, |
||||
"15" => { |
||||
"value" => "Children's social care", |
||||
}, |
||||
"16" => { |
||||
"value" => "Police, probation, prison or youth offending team following a custodial sentence", |
||||
}, |
||||
"17" => { |
||||
"value" => "Police, probation, prison or youth offending team without a custodial sentence", |
||||
}, |
||||
"18" => { |
||||
"value" => "Voluntary agency", |
||||
}, |
||||
"19" => { |
||||
"value" => "Other third party", |
||||
}, |
||||
"20" => { |
||||
"value" => "Don't know", |
||||
}, |
||||
}.freeze, |
||||
) |
||||
end |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(question.question_number).to eq(92) |
||||
end |
||||
end |
||||
@ -0,0 +1,104 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Lettings::Questions::ReferralRegister, type: :model do |
||||
subject(:question) { described_class.new(question_id, question_definition, page, provider_type) } |
||||
|
||||
let(:question_id) { nil } |
||||
let(:question_definition) { nil } |
||||
let(:page) { instance_double(Form::Page) } |
||||
let(:provider_type) { nil } |
||||
let(:subsection) { instance_double(Form::Subsection) } |
||||
let(:form) { instance_double(Form, start_date: Time.zone.today) } |
||||
let(:is_renewal?) { nil } |
||||
let(:log) { instance_double(LettingsLog, is_renewal?: is_renewal?) } |
||||
|
||||
before do |
||||
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_register") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
context "when log is a renewal" do |
||||
let(:is_renewal?) { true } |
||||
|
||||
it "is marked as derived" do |
||||
expect(question.derived?(log)).to be true |
||||
end |
||||
end |
||||
|
||||
context "when log is not a renewal" do |
||||
let(:is_renewal?) { false } |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?(log)).to be false |
||||
end |
||||
end |
||||
|
||||
context "when log is owned by an LA" do |
||||
let(:provider_type) { :la } |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"1" => { |
||||
"value" => "Renewal to the same tenant in the same property", |
||||
}, |
||||
"2" => { |
||||
"value" => "Internal transfer from another property owned by the same local authority - for existing social tenants only", |
||||
}, |
||||
"3" => { |
||||
"value" => "From a housing register (waiting list)", |
||||
}, |
||||
"4" => { |
||||
"value" => "Tenant applied directly (not via a nomination or housing register)", |
||||
}, |
||||
}.freeze, |
||||
) |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(question.question_number).to eq(91) |
||||
end |
||||
end |
||||
|
||||
context "when log is owned by an PRP" do |
||||
let(:provider_type) { :prp } |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq( |
||||
{ |
||||
"5" => { |
||||
"value" => "Renewal to the same tenant in the same property", |
||||
}, |
||||
"6" => { |
||||
"value" => "From a local authority housing register (waiting list) or a register with local authority involvement", |
||||
}, |
||||
"7" => { |
||||
"value" => "From a housing register (waiting list) with no local authority involvement", |
||||
}, |
||||
"8" => { |
||||
"value" => "Tenant applied directly (not via a nomination or waiting list)", |
||||
}, |
||||
"9" => { |
||||
"value" => "Don't know", |
||||
}, |
||||
}.freeze, |
||||
) |
||||
end |
||||
|
||||
it "has the correct question_number" do |
||||
expect(question.question_number).to eq(92) |
||||
end |
||||
end |
||||
end |
||||
Loading…
Reference in new issue