Browse Source

CLDC-3556: Ignore address data in bulk upload for supported housing logs (#2540)

* Only set address data in BU for general needs logs

* Don't route to uprn selection page for supported housing logs

* Fix tests
pull/2577/head
Rachael Booth 5 months ago committed by GitHub
parent
commit
85bbbe6108
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/form/lettings/pages/uprn_selection.rb
  2. 43
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  3. 44
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

2
app/models/form/lettings/pages/uprn_selection.rb

@ -17,7 +17,7 @@ class Form::Lettings::Pages::UprnSelection < ::Form::Page
end
def routed_to?(log, _current_user = nil)
(log.uprn_known.nil? || log.uprn_known.zero?) && log.address_line1_input.present? && log.postcode_full_input.present? && (1..10).cover?(log.address_options&.count)
!log.is_supported_housing? && (log.uprn_known.nil? || log.uprn_known.zero?) && log.address_line1_input.present? && log.postcode_full_input.present? && (1..10).cover?(log.address_options&.count)
end
def skip_text

43
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -1130,10 +1130,6 @@ private
attributes["lettype"] = nil # should get this from rent_type
attributes["tenancycode"] = field_13
attributes["la"] = field_23
attributes["la_as_entered"] = field_23
attributes["postcode_known"] = postcode_known
attributes["postcode_full"] = postcode_full
attributes["owning_organisation"] = owning_organisation
attributes["managing_organisation"] = managing_organisation
attributes["renewal"] = renewal
@ -1304,22 +1300,29 @@ private
attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing
attributes["uprn_known"] = field_16.present? ? 1 : 0
attributes["uprn_confirmed"] = 1 if field_16.present?
attributes["skip_update_uprn_confirmed"] = true
attributes["uprn"] = field_16
attributes["address_line1"] = field_17
attributes["address_line1_as_entered"] = field_17
attributes["address_line2"] = field_18
attributes["address_line2_as_entered"] = field_18
attributes["town_or_city"] = field_19
attributes["town_or_city_as_entered"] = field_19
attributes["county"] = field_20
attributes["county_as_entered"] = field_20
attributes["address_line1_input"] = address_line1_input
attributes["postcode_full_input"] = postcode_full
attributes["postcode_full_as_entered"] = postcode_full
attributes["select_best_address_match"] = true if field_16.blank? && !supported_housing?
if general_needs?
attributes["uprn_known"] = field_16.present? ? 1 : 0
attributes["uprn_confirmed"] = 1 if field_16.present?
attributes["skip_update_uprn_confirmed"] = true
attributes["uprn"] = field_16
attributes["address_line1"] = field_17
attributes["address_line1_as_entered"] = field_17
attributes["address_line2"] = field_18
attributes["address_line2_as_entered"] = field_18
attributes["town_or_city"] = field_19
attributes["town_or_city_as_entered"] = field_19
attributes["county"] = field_20
attributes["county_as_entered"] = field_20
attributes["postcode_full"] = postcode_full
attributes["postcode_full_as_entered"] = postcode_full
attributes["postcode_known"] = postcode_known
attributes["la"] = field_23
attributes["la_as_entered"] = field_23
attributes["address_line1_input"] = address_line1_input
attributes["postcode_full_input"] = postcode_full
attributes["select_best_address_match"] = true if field_16.blank?
end
attributes
end

44
spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb

@ -1867,7 +1867,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#uprn" do
let(:attributes) { { bulk_upload:, field_16: "12" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_16: "12" } }
it "sets to given value" do
expect(parser.log.uprn).to eql("12")
@ -1876,7 +1876,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
describe "#uprn_known" do
context "when uprn specified" do
let(:attributes) { { bulk_upload:, field_16: "12" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_16: "12" } }
it "sets to 1" do
expect(parser.log.uprn_known).to be(1)
@ -1885,7 +1885,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
context "when uprn blank" do
let(:attributes) { { bulk_upload:, field_16: "", field_4: 1 } }
let(:attributes) { { bulk_upload:, field_4: 1, field_16: "" } }
it "sets to 0" do
expect(parser.log.uprn_known).to be(0)
@ -1894,7 +1894,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#address_line1" do
let(:attributes) { { bulk_upload:, field_17: "123 Sesame Street" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_17: "123 Sesame Street" } }
it "sets to given value" do
expect(parser.log.address_line1).to eql("123 Sesame Street")
@ -1902,7 +1902,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#address_line2" do
let(:attributes) { { bulk_upload:, field_18: "Cookie Town" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_18: "Cookie Town" } }
it "sets to given value" do
expect(parser.log.address_line2).to eql("Cookie Town")
@ -1910,7 +1910,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#town_or_city" do
let(:attributes) { { bulk_upload:, field_19: "London" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_19: "London" } }
it "sets to given value" do
expect(parser.log.town_or_city).to eql("London")
@ -1918,13 +1918,39 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#county" do
let(:attributes) { { bulk_upload:, field_20: "Greater London" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_20: "Greater London" } }
it "sets to given value" do
expect(parser.log.county).to eql("Greater London")
end
end
describe "address related fields for supported housing logs" do
context "when address data is provided for a supported housing log" do
let(:attributes) { { bulk_upload:, field_4: 2, field_16: nil, field_17: "Flat 1", field_18: "Example Place", field_19: "London", field_20: "Greater London", field_21: "SW1A", field_22: "1AA" } }
it "is not set on the log" do
expect(parser.log.uprn).to be_nil
expect(parser.log.uprn_known).to be_nil
expect(parser.log.address_line1).to be_nil
expect(parser.log.address_line1_as_entered).to be_nil
expect(parser.log.address_line2).to be_nil
expect(parser.log.address_line2_as_entered).to be_nil
expect(parser.log.town_or_city).to be_nil
expect(parser.log.town_or_city_as_entered).to be_nil
expect(parser.log.county).to be_nil
expect(parser.log.county_as_entered).to be_nil
expect(parser.log.postcode_full).to be_nil
expect(parser.log.postcode_full_as_entered).to be_nil
expect(parser.log.la).to be_nil
expect(parser.log.la_as_entered).to be_nil
expect(parser.log.address_line1_input).to be_nil
expect(parser.log.postcode_full_input).to be_nil
expect(parser.log.select_best_address_match).to be_nil
end
end
end
[
%w[age1_known details_known_1 age1 field_42 field_47 field_49],
%w[age2_known details_known_2 age2 field_48 field_47 field_49],
@ -2611,7 +2637,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#postcode_full" do
let(:attributes) { { bulk_upload:, field_21: " EC1N ", field_22: " 2TD " } }
let(:attributes) { { bulk_upload:, field_4: 1, field_21: " EC1N ", field_22: " 2TD " } }
it "strips whitespace" do
expect(parser.log.postcode_full).to eql("EC1N 2TD")
@ -2619,7 +2645,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end
describe "#la" do
let(:attributes) { { bulk_upload:, field_23: "E07000223" } }
let(:attributes) { { bulk_upload:, field_4: 1, field_23: "E07000223" } }
it "sets to given value" do
expect(parser.log.la).to eql("E07000223")

Loading…
Cancel
Save