From 5b5e29a84a556eb067d4cb855af261111876f38d Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:09:33 +0000 Subject: [PATCH] CLDC-3310 UPRN routing bug fix (#2312) * feat: update routing * feat: test routing --- app/models/form/lettings/pages/no_address_found.rb | 6 +++++- .../form/lettings/pages/property_local_authority.rb | 4 +++- app/models/form/lettings/pages/uprn_selection.rb | 6 +++++- app/models/form/sales/pages/no_address_found.rb | 7 ++++++- .../form/sales/pages/property_local_authority.rb | 6 +++--- app/models/form/sales/pages/uprn_selection.rb | 6 +++++- app/models/lettings_log.rb | 4 ++++ app/models/sales_log.rb | 4 ++++ .../form/lettings/pages/no_address_found_spec.rb | 10 +++++++++- .../lettings/pages/property_local_authority_spec.rb | 4 +++- spec/models/form/lettings/pages/uprn_selection_spec.rb | 10 +++++++++- spec/models/form/sales/pages/no_address_found_spec.rb | 4 +++- .../form/sales/pages/property_local_authority_spec.rb | 4 +--- spec/models/form/sales/pages/uprn_selection_spec.rb | 4 +++- 14 files changed, 63 insertions(+), 16 deletions(-) diff --git a/app/models/form/lettings/pages/no_address_found.rb b/app/models/form/lettings/pages/no_address_found.rb index 23eba8eed..b1a78caf6 100644 --- a/app/models/form/lettings/pages/no_address_found.rb +++ b/app/models/form/lettings/pages/no_address_found.rb @@ -11,7 +11,11 @@ class Form::Lettings::Pages::NoAddressFound < ::Form::Page "translation" => "soft_validations.no_address_found.informative_text", "arguments" => [], } - @depends_on = [{ "address_options_present?" => false }] + @depends_on = [ + { "is_supported_housing?" => false, "uprn_known" => nil, "address_options_present?" => false }, + { "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => false }, + { "is_supported_housing?" => false, "uprn_confirmed" => 0, "address_options_present?" => false }, + ] end def questions diff --git a/app/models/form/lettings/pages/property_local_authority.rb b/app/models/form/lettings/pages/property_local_authority.rb index 2c64e3628..9b36b0936 100644 --- a/app/models/form/lettings/pages/property_local_authority.rb +++ b/app/models/form/lettings/pages/property_local_authority.rb @@ -2,7 +2,9 @@ class Form::Lettings::Pages::PropertyLocalAuthority < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_local_authority" - @depends_on = [{ "is_la_inferred" => false, "is_general_needs?" => true }] + @depends_on = [ + { "is_la_inferred" => false, "is_general_needs?" => true, "address_search_given?" => true }, + ] end def questions diff --git a/app/models/form/lettings/pages/uprn_selection.rb b/app/models/form/lettings/pages/uprn_selection.rb index 521c1e270..8d3640740 100644 --- a/app/models/form/lettings/pages/uprn_selection.rb +++ b/app/models/form/lettings/pages/uprn_selection.rb @@ -3,7 +3,11 @@ class Form::Lettings::Pages::UprnSelection < ::Form::Page super @id = "uprn_selection" @header = "We found some addresses that might be this property" - @depends_on = [{ "address_options_present?" => true }] + @depends_on = [ + { "is_supported_housing?" => false, "uprn_known" => nil, "address_options_present?" => true }, + { "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => true }, + { "is_supported_housing?" => false, "uprn_confirmed" => 0, "address_options_present?" => true }, + ] end def questions diff --git a/app/models/form/sales/pages/no_address_found.rb b/app/models/form/sales/pages/no_address_found.rb index a37408379..6e3b04f40 100644 --- a/app/models/form/sales/pages/no_address_found.rb +++ b/app/models/form/sales/pages/no_address_found.rb @@ -11,7 +11,12 @@ class Form::Sales::Pages::NoAddressFound < ::Form::Page "translation" => "soft_validations.no_address_found.informative_text", "arguments" => [], } - @depends_on = [{ "address_options_present?" => false }] + @depends_on = [ + { "uprn_known" => nil, "address_options_present?" => false }, + { "uprn_known" => 0, "address_options_present?" => false }, + { "uprn_confirmed" => 0, "address_options_present?" => false }, + + ] end def questions diff --git a/app/models/form/sales/pages/property_local_authority.rb b/app/models/form/sales/pages/property_local_authority.rb index 81d4382d9..59403a20c 100644 --- a/app/models/form/sales/pages/property_local_authority.rb +++ b/app/models/form/sales/pages/property_local_authority.rb @@ -2,9 +2,9 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_local_authority" - @depends_on = [{ - "is_la_inferred" => false, - }] + @depends_on = [ + { "is_la_inferred" => false, "address_search_given?" => true }, + ] end def questions diff --git a/app/models/form/sales/pages/uprn_selection.rb b/app/models/form/sales/pages/uprn_selection.rb index 71ab3c5ac..1c7f251ac 100644 --- a/app/models/form/sales/pages/uprn_selection.rb +++ b/app/models/form/sales/pages/uprn_selection.rb @@ -3,7 +3,11 @@ class Form::Sales::Pages::UprnSelection < ::Form::Page super @id = "uprn_selection" @header = "We found some addresses that might be this property" - @depends_on = [{ "address_options_present?" => true }] + @depends_on = [ + { "uprn_known" => nil, "address_options_present?" => true }, + { "uprn_known" => 0, "address_options_present?" => true }, + { "uprn_confirmed" => 0, "address_options_present?" => true }, + ] end def questions diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 584158000..5d56e53c7 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -694,6 +694,10 @@ class LettingsLog < Log LettingsLog.where.not(duplicate_set_id: nil).where(duplicate_set_id:).where.not(id:) end + def address_search_given? + address_line1_input.present? && postcode_full.present? + end + private def reset_invalid_unresolved_log_fields! diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index e75e4bb55..f35393a51 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -530,4 +530,8 @@ class SalesLog < Log def stairowned_100? stairowned == 100 end + + def address_search_given? + address_line1_input.present? && postcode_full.present? + end end diff --git a/spec/models/form/lettings/pages/no_address_found_spec.rb b/spec/models/form/lettings/pages/no_address_found_spec.rb index 34ef22b2a..3f5dd7695 100644 --- a/spec/models/form/lettings/pages/no_address_found_spec.rb +++ b/spec/models/form/lettings/pages/no_address_found_spec.rb @@ -25,7 +25,15 @@ RSpec.describe Form::Lettings::Pages::NoAddressFound, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "address_options_present?" => false }]) + expect(page.depends_on).to eq([{ "address_options_present?" => false, + "is_supported_housing?" => false, + "uprn_known" => nil }, + { "address_options_present?" => false, + "is_supported_housing?" => false, + "uprn_known" => 0 }, + { "address_options_present?" => false, + "is_supported_housing?" => false, + "uprn_confirmed" => 0 }]) end it "is interruption screen page" do diff --git a/spec/models/form/lettings/pages/property_local_authority_spec.rb b/spec/models/form/lettings/pages/property_local_authority_spec.rb index c09d01dc7..1936587b0 100644 --- a/spec/models/form/lettings/pages/property_local_authority_spec.rb +++ b/spec/models/form/lettings/pages/property_local_authority_spec.rb @@ -33,6 +33,8 @@ RSpec.describe Form::Lettings::Pages::PropertyLocalAuthority, type: :model do end it "has the correct depends_on" do - expect(page.depends_on).to match([{ "is_general_needs?" => true, "is_la_inferred" => false }]) + expect(page.depends_on).to match([{ "address_search_given?" => true, + "is_general_needs?" => true, + "is_la_inferred" => false }]) end end diff --git a/spec/models/form/lettings/pages/uprn_selection_spec.rb b/spec/models/form/lettings/pages/uprn_selection_spec.rb index f9ca20894..89e2424d2 100644 --- a/spec/models/form/lettings/pages/uprn_selection_spec.rb +++ b/spec/models/form/lettings/pages/uprn_selection_spec.rb @@ -39,6 +39,14 @@ RSpec.describe Form::Lettings::Pages::UprnSelection, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "address_options_present?" => true }]) + expect(page.depends_on).to eq([{ "address_options_present?" => true, + "is_supported_housing?" => false, + "uprn_known" => nil }, + { "address_options_present?" => true, + "is_supported_housing?" => false, + "uprn_known" => 0 }, + { "address_options_present?" => true, + "is_supported_housing?" => false, + "uprn_confirmed" => 0 }]) end end diff --git a/spec/models/form/sales/pages/no_address_found_spec.rb b/spec/models/form/sales/pages/no_address_found_spec.rb index e275892bf..79b2bd0ca 100644 --- a/spec/models/form/sales/pages/no_address_found_spec.rb +++ b/spec/models/form/sales/pages/no_address_found_spec.rb @@ -25,7 +25,9 @@ RSpec.describe Form::Sales::Pages::NoAddressFound, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "address_options_present?" => false }]) + expect(page.depends_on).to eq([{ "address_options_present?" => false, "uprn_known" => nil }, + { "address_options_present?" => false, "uprn_known" => 0 }, + { "address_options_present?" => false, "uprn_confirmed" => 0 }]) end it "is interruption screen page" do diff --git a/spec/models/form/sales/pages/property_local_authority_spec.rb b/spec/models/form/sales/pages/property_local_authority_spec.rb index 55234ad52..49c39f8e9 100644 --- a/spec/models/form/sales/pages/property_local_authority_spec.rb +++ b/spec/models/form/sales/pages/property_local_authority_spec.rb @@ -52,8 +52,6 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do end it "has the correct depends_on" do - expect(page.depends_on).to eq([{ - "is_la_inferred" => false, - }]) + expect(page.depends_on).to eq([{ "address_search_given?" => true, "is_la_inferred" => false }]) end end diff --git a/spec/models/form/sales/pages/uprn_selection_spec.rb b/spec/models/form/sales/pages/uprn_selection_spec.rb index 28c904c58..75fc6ae24 100644 --- a/spec/models/form/sales/pages/uprn_selection_spec.rb +++ b/spec/models/form/sales/pages/uprn_selection_spec.rb @@ -39,6 +39,8 @@ RSpec.describe Form::Sales::Pages::UprnSelection, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "address_options_present?" => true }]) + expect(page.depends_on).to eq([{ "address_options_present?" => true, "uprn_known" => nil }, + { "address_options_present?" => true, "uprn_known" => 0 }, + { "address_options_present?" => true, "uprn_confirmed" => 0 }]) end end