Browse Source

CLDC-2636 Fix enter address instead bug (#2014)

* feat: route address question when uprn_known has not yet been answered

* refactor

* feat: update tests

* feat: update tests

* feat: update routed_to? and tests

* refactor: lint
pull/2015/head
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
b255627fa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/models/form/lettings/pages/address.rb
  2. 4
      app/models/form/sales/pages/address.rb
  3. 4
      app/models/form/sales/pages/uprn.rb
  4. 5
      spec/factories/lettings_log.rb
  5. 10
      spec/models/form/lettings/pages/address_spec.rb
  6. 6
      spec/models/form/sales/pages/address_spec.rb

3
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

4
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

4
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

5
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

10
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

6
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

Loading…
Cancel
Save