From fc3b5918b2ad695dd22b8a3d796e9800f6568329 Mon Sep 17 00:00:00 2001 From: Jack S Date: Wed, 15 Mar 2023 17:15:35 +0000 Subject: [PATCH] Skip to non addresss questions if UPRN unknown --- app/models/form/sales/pages/address.rb | 4 +++- app/models/form/sales/pages/property_local_authority.rb | 6 ++++++ .../form/sales/pages/property_local_authority_spec.rb | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/form/sales/pages/address.rb b/app/models/form/sales/pages/address.rb index dc66ca3fc..453797d7b 100644 --- a/app/models/form/sales/pages/address.rb +++ b/app/models/form/sales/pages/address.rb @@ -16,6 +16,8 @@ class Form::Sales::Pages::Address < ::Form::Page end def routed_to?(log, _current_user) - log.uprn_confirmed != 1 || log.uprn_known&.zero? + return false if log.uprn_known.nil? + + log.uprn_confirmed != 1 || log.uprn_known.zero? end end diff --git a/app/models/form/sales/pages/property_local_authority.rb b/app/models/form/sales/pages/property_local_authority.rb index 7e63b2f6c..b7255c1ae 100644 --- a/app/models/form/sales/pages/property_local_authority.rb +++ b/app/models/form/sales/pages/property_local_authority.rb @@ -13,4 +13,10 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page Form::Sales::Questions::PropertyLocalAuthority.new(nil, nil, self), ] end + + def routed_to?(log, _current_user) + return false if log.uprn_known.nil? && form.start_date.year >= 2023 + + super + end end 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 d601a53ce..a699b2188 100644 --- a/spec/models/form/sales/pages/property_local_authority_spec.rb +++ b/spec/models/form/sales/pages/property_local_authority_spec.rb @@ -38,4 +38,7 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do "is_la_inferred" => false, }]) end + + xit "it has the correct routed_to?" do + end end