Browse Source

CLDC-3337 Uprn confirmed routing bug fix (#2327)

* feat: update derived variables to clear uprn_confirmed when uprn_known is 0

* feat: reset other address fields when uprn is not confirmed

* feat: use pcodenk in sales logs
pull/2339/head
natdeanlewissoftwire 9 months ago committed by GitHub
parent
commit
a1059ef31c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      app/models/derived_variables/lettings_log_variables.rb
  2. 10
      app/models/derived_variables/sales_log_variables.rb
  3. 18
      spec/shared/shared_examples_for_derived_fields.rb

10
app/models/derived_variables/lettings_log_variables.rb

@ -113,9 +113,17 @@ module DerivedVariables::LettingsLogVariables
self.uprn = nil
end
if uprn_confirmed&.zero?
if uprn_known == 1 && uprn_confirmed&.zero?
self.uprn = nil
self.uprn_known = 0
self.uprn_confirmed = nil
self.address_line1 = nil
self.address_line2 = nil
self.town_or_city = nil
self.county = nil
self.postcode_known = nil
self.postcode_full = nil
self.la = nil
end
self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say?

10
app/models/derived_variables/sales_log_variables.rb

@ -45,9 +45,17 @@ module DerivedVariables::SalesLogVariables
self.uprn = nil
end
if uprn_confirmed&.zero?
if uprn_known == 1 && uprn_confirmed&.zero?
self.uprn = nil
self.uprn_known = 0
self.uprn_confirmed = nil
self.address_line1 = nil
self.address_line2 = nil
self.town_or_city = nil
self.county = nil
self.pcodenk = nil
self.postcode_full = nil
self.la = nil
end
self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say?

18
spec/shared/shared_examples_for_derived_fields.rb

@ -14,4 +14,22 @@ RSpec.shared_examples "shared examples for derived fields" do |log_type|
expect { log.set_derived_fields! }.not_to change(log, :ethnic)
end
end
context "when uprn is not confirmed" do
it "derives other uprn fields correctly" do
log = FactoryBot.build(log_type, uprn_known: 1, uprn: 1, uprn_confirmed: 0)
expect { log.set_derived_fields! }.to change(log, :uprn_known).from(1).to(0)
.and change(log, :uprn).from("1").to(nil)
.and change(log, :uprn_confirmed).from(0).to(nil)
end
it "does not affect older logs with uprn_confirmed == 0" do
log = FactoryBot.build(log_type, uprn_known: 0, uprn: nil, uprn_confirmed: 0)
expect { log.set_derived_fields! }.to not_change(log, :uprn_known)
.and not_change(log, :uprn)
.and not_change(log, :uprn_confirmed)
end
end
end

Loading…
Cancel
Save