diff --git a/app/models/form/lettings/pages/address.rb b/app/models/form/lettings/pages/address.rb index cf6f73036..389ce172a 100644 --- a/app/models/form/lettings/pages/address.rb +++ b/app/models/form/lettings/pages/address.rb @@ -16,9 +16,8 @@ class Form::Lettings::Pages::Address < ::Form::Page end def routed_to?(log, _current_user = nil) - return false if log.uprn_known.nil? return false if log.is_supported_housing? - log.uprn_confirmed != 1 || log.uprn_known.zero? + log.uprn_known.nil? || log.uprn_known.zero? || log.uprn_confirmed&.zero? end end diff --git a/app/models/form/sales/pages/address.rb b/app/models/form/sales/pages/address.rb index d68bf470a..134dcdccc 100644 --- a/app/models/form/sales/pages/address.rb +++ b/app/models/form/sales/pages/address.rb @@ -16,8 +16,6 @@ class Form::Sales::Pages::Address < ::Form::Page end def routed_to?(log, _current_user = nil) - return false if log.uprn_known.nil? - - log.uprn_known.zero? || log.uprn_confirmed&.zero? + log.uprn_known.nil? || log.uprn_known.zero? || log.uprn_confirmed&.zero? end end diff --git a/app/models/form/sales/pages/uprn.rb b/app/models/form/sales/pages/uprn.rb index c4ae5b357..6df3aaab7 100644 --- a/app/models/form/sales/pages/uprn.rb +++ b/app/models/form/sales/pages/uprn.rb @@ -11,6 +11,10 @@ class Form::Sales::Pages::Uprn < ::Form::Page ] end + def routed_to?(_log, _current_user) + true + end + def skip_text "Enter address instead" end diff --git a/spec/factories/lettings_log.rb b/spec/factories/lettings_log.rb index e661645c7..f01d6b4a4 100644 --- a/spec/factories/lettings_log.rb +++ b/spec/factories/lettings_log.rb @@ -3,7 +3,10 @@ FactoryBot.define do created_by { FactoryBot.create(:user) } owning_organisation { created_by.organisation } managing_organisation { created_by.organisation } + created_at { Time.zone.today } + updated_at { Time.zone.today } trait :setup_completed do + startdate_today renewal { 0 } needstype { 1 } rent_type { 1 } @@ -206,7 +209,5 @@ FactoryBot.define do illness_type_9 { false } illness_type_10 { false } end - created_at { Time.zone.today } - updated_at { Time.zone.today } end end diff --git a/spec/models/form/lettings/pages/address_spec.rb b/spec/models/form/lettings/pages/address_spec.rb index 276b5c756..71f61d2e8 100644 --- a/spec/models/form/lettings/pages/address_spec.rb +++ b/spec/models/form/lettings/pages/address_spec.rb @@ -35,14 +35,14 @@ RSpec.describe Form::Lettings::Pages::Address, type: :model do context "when uprn_known == nil" do let(:log) { create(:lettings_log, uprn_known: nil) } - it "returns false" do - expect(page.routed_to?(log)).to eq(false) + it "returns true" do + expect(page.routed_to?(log)).to eq(true) end end context "when uprn_confirmed != 1" do let(:log) do - create(:lettings_log, uprn_known: 1, uprn_confirmed: 0) + create(:lettings_log, uprn_known: 1, uprn: "12345", uprn_confirmed: 0) end it "returns true" do @@ -62,10 +62,10 @@ RSpec.describe Form::Lettings::Pages::Address, type: :model do context "when uprn_confirmed == 1 && uprn_known != 0" do let(:log) do - create(:lettings_log, uprn_known: 1, uprn_confirmed: 1, uprn: "123456789") + create(:lettings_log, uprn_known: 1, uprn: "12345", uprn_confirmed: 1) end - it "returns true" do + it "returns false" do expect(page.routed_to?(log)).to eq(false) end end diff --git a/spec/models/form/sales/pages/address_spec.rb b/spec/models/form/sales/pages/address_spec.rb index 165952cfb..9bdd5f432 100644 --- a/spec/models/form/sales/pages/address_spec.rb +++ b/spec/models/form/sales/pages/address_spec.rb @@ -35,8 +35,8 @@ RSpec.describe Form::Sales::Pages::Address, type: :model do context "when uprn_known == nil" do let(:log) { create(:sales_log, uprn_known: nil) } - it "returns false" do - expect(page.routed_to?(log)).to eq(false) + it "returns true" do + expect(page.routed_to?(log)).to eq(true) end end @@ -66,7 +66,7 @@ RSpec.describe Form::Sales::Pages::Address, type: :model do create(:sales_log, uprn_known: 1, uprn: "12345", uprn_confirmed: 1) end - it "returns true" do + it "returns false" do expect(page.routed_to?(log)).to eq(false) end end