Browse Source

bulk upload maps new field errors (#1471)

pull/1473/head
Phil Lee 2 years ago committed by GitHub
parent
commit
be6e6585bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 23
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

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

@ -766,6 +766,12 @@ private
mrcdate: %i[field_36 field_37 field_38], mrcdate: %i[field_36 field_37 field_38],
voiddate: %i[field_33 field_34 field_35], voiddate: %i[field_33 field_34 field_35],
uprn: [:field_18],
address_line1: [:field_19],
address_line2: [:field_20],
town_or_city: [:field_21],
county: [:field_22],
} }
end end

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

@ -63,8 +63,19 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
stub_request(:get, /api.postcodes.io/) stub_request(:get, /api.postcodes.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {}) .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
body = {
results: [
{
DPA: {
"POSTCODE": "EC1N 2TD",
"POST_TOWN": "Newcastle",
},
},
],
}.to_json
stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=100023336956") stub_request(:get, "https://api.os.uk/search/places/v1/uprn?key=OS_DATA_KEY&uprn=100023336956")
.to_return(status: 200, body: "{}", headers: {}) .to_return(status: 200, body:, headers: {})
parser.valid? parser.valid?
end end
@ -712,6 +723,16 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
end end
describe "#field_18" do # UPRN
context "when over 12 characters" do
let(:attributes) { { bulk_upload:, field_18: "1234567890123" } }
it "has errors on the field" do
expect(parser.errors[:field_18]).to be_present
end
end
end
describe "#field_30" do describe "#field_30" do
context "when null" do context "when null" do
let(:attributes) { setup_section_params.merge({ field_30: nil }) } let(:attributes) { setup_section_params.merge({ field_30: nil }) }

Loading…
Cancel
Save