Browse Source

add new uprn and address fields to bulk upload (#1462)

bulk-upload-sentence-case
Phil Lee 2 years ago committed by GitHub
parent
commit
0b973ceebd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 63
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  3. 10
      spec/support/bulk_upload/log_to_csv.rb

7
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -939,6 +939,13 @@ private
attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing
attributes["uprn_known"] = field_18.present? ? 1 : 0
attributes["uprn"] = field_18
attributes["address_line1"] = field_19
attributes["address_line2"] = field_20
attributes["town_or_city"] = field_21
attributes["county"] = field_22
attributes
end

63
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -63,6 +63,9 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=100023336956")
.to_return(status: 200, body: "{}", headers: {})
parser.valid?
end
@ -198,6 +201,8 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
field_35: now.strftime("%g"),
field_4: "1",
field_18: "100023336956",
}
end
@ -689,6 +694,64 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end
describe "#log" do
describe "#uprn" do
let(:attributes) { { bulk_upload:, field_18: "100023336956" } }
it "sets to given value" do
expect(parser.log.uprn).to eql("100023336956")
end
end
describe "#uprn_known" do
context "when uprn specified" do
let(:attributes) { { bulk_upload:, field_18: "100023336956" } }
it "sets to 1" do
expect(parser.log.uprn_known).to be(1)
end
end
context "when uprn blank" do
let(:attributes) { { bulk_upload:, field_18: "" } }
it "sets to 0" do
expect(parser.log.uprn_known).to be(0)
end
end
end
describe "#address_line1" do
let(:attributes) { { bulk_upload:, field_19: "123 Sesame Street" } }
it "sets to given value" do
expect(parser.log.address_line1).to eql("123 Sesame Street")
end
end
describe "#address_line2" do
let(:attributes) { { bulk_upload:, field_20: "Cookie Town" } }
it "sets to given value" do
expect(parser.log.address_line2).to eql("Cookie Town")
end
end
describe "#town_or_city" do
let(:attributes) { { bulk_upload:, field_21: "London" } }
it "sets to given value" do
expect(parser.log.town_or_city).to eql("London")
end
end
describe "#county" do
let(:attributes) { { bulk_upload:, field_22: "Greater London" } }
it "sets to given value" do
expect(parser.log.county).to eql("Greater London")
end
end
[
%w[age1_known age1 field_46],
%w[age2_known age2 field_52],

10
spec/support/bulk_upload/log_to_csv.rb

@ -29,11 +29,11 @@ class BulkUpload::LogToCsv
to_2022_row + [
log.needstype,
log.location&.id,
nil, # uprn,
nil, # address_line_1,
nil, # address_line_2,
nil, # town_or_city,
nil, # county,
log.uprn,
log.address_line1,
log.address_line2,
log.town_or_city,
log.county,
]
end

Loading…
Cancel
Save