Browse Source

CLDC-2636.2 set uprn known no when routing to address from uprn page (#2054)

* feat: infer uprn_known as No if the user answers address (through "Enter address instead" route/check answers page)

* feat: update tests

* refactor: lint

* feat: add 2023 check and sales behaviour
pull/2059/head
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
8f48771a41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/models/derived_variables/lettings_log_variables.rb
  2. 6
      app/models/derived_variables/sales_log_variables.rb
  3. 4
      spec/models/form/lettings/questions/uprn_spec.rb
  4. 5
      spec/models/form/sales/questions/uprn_spec.rb

6
app/models/derived_variables/lettings_log_variables.rb

@ -95,6 +95,8 @@ module DerivedVariables::LettingsLogVariables
set_housingneeds_fields if housingneeds? set_housingneeds_fields if housingneeds?
self.uprn_known = 0 if address_answered_without_uprn?
if uprn_known&.zero? if uprn_known&.zero?
self.uprn = nil self.uprn = nil
end end
@ -310,6 +312,10 @@ private
self.county = nil self.county = nil
end end
def address_answered_without_uprn?
[address_line1, town_or_city].all?(&:present?) && uprn.nil? && form.start_date.year >= 2023
end
def get_lar def get_lar
return 1 if rent_type == 2 return 1 if rent_type == 2
return 2 if rent_type == 1 return 2 if rent_type == 1

6
app/models/derived_variables/sales_log_variables.rb

@ -24,6 +24,8 @@ module DerivedVariables::SalesLogVariables
self.hhmemb = number_of_household_members self.hhmemb = number_of_household_members
self.hhtype = household_type self.hhtype = household_type
self.uprn_known = 0 if address_answered_without_uprn?
if uprn_known&.zero? if uprn_known&.zero?
self.uprn = nil self.uprn = nil
end end
@ -148,4 +150,8 @@ private
def only_one_elder? def only_one_elder?
total_elder == 1 && total_adult.zero? && totchild.zero? total_elder == 1 && total_adult.zero? && totchild.zero?
end end
def address_answered_without_uprn?
[address_line1, town_or_city].all?(&:present?) && uprn.nil? && form.start_date.year >= 2023
end
end end

4
spec/models/form/lettings/questions/uprn_spec.rb

@ -62,11 +62,13 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
postcode_full: "AA1 1AA", postcode_full: "AA1 1AA",
la: "E09000003", la: "E09000003",
uprn_known:, uprn_known:,
uprn:,
) )
end end
context "when uprn known nil" do context "when uprn known nil" do
let(:uprn_known) { nil } let(:uprn_known) { nil }
let(:uprn) { nil }
it "returns formatted value" do it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to be_nil expect(question.get_extra_check_answer_value(log)).to be_nil
@ -75,6 +77,7 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
context "when uprn known" do context "when uprn known" do
let(:uprn_known) { 1 } let(:uprn_known) { 1 }
let(:uprn) { 123_456_789 }
it "returns formatted value" do it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to eq( expect(question.get_extra_check_answer_value(log)).to eq(
@ -85,6 +88,7 @@ RSpec.describe Form::Lettings::Questions::Uprn, type: :model do
context "when uprn not known" do context "when uprn not known" do
let(:uprn_known) { 0 } let(:uprn_known) { 0 }
let(:uprn) { nil }
it "returns formatted value" do it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to be_nil expect(question.get_extra_check_answer_value(log)).to be_nil

5
spec/models/form/sales/questions/uprn_spec.rb

@ -56,18 +56,19 @@ RSpec.describe Form::Sales::Questions::Uprn, type: :model do
let(:log) do let(:log) do
create( create(
:sales_log, :sales_log,
:completed,
address_line1: "1, Test Street", address_line1: "1, Test Street",
town_or_city: "Test Town", town_or_city: "Test Town",
county: "Test County", county: "Test County",
postcode_full: "AA1 1AA", postcode_full: "AA1 1AA",
la: "E09000003", la: "E09000003",
uprn_known:, uprn_known:,
uprn:,
) )
end end
context "when uprn known nil" do context "when uprn known nil" do
let(:uprn_known) { nil } let(:uprn_known) { nil }
let(:uprn) { nil }
it "returns formatted value" do it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to be_nil expect(question.get_extra_check_answer_value(log)).to be_nil
@ -76,6 +77,7 @@ RSpec.describe Form::Sales::Questions::Uprn, type: :model do
context "when uprn known" do context "when uprn known" do
let(:uprn_known) { 1 } let(:uprn_known) { 1 }
let(:uprn) { 123_456_789 }
it "returns formatted value" do it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to eq( expect(question.get_extra_check_answer_value(log)).to eq(
@ -86,6 +88,7 @@ RSpec.describe Form::Sales::Questions::Uprn, type: :model do
context "when uprn not known" do context "when uprn not known" do
let(:uprn_known) { 0 } let(:uprn_known) { 0 }
let(:uprn) { nil }
it "returns formatted value" do it "returns formatted value" do
expect(question.get_extra_check_answer_value(log)).to be_nil expect(question.get_extra_check_answer_value(log)).to be_nil

Loading…
Cancel
Save