From f662536c14f00b9cbbe34676f6decb71b4786461 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Tue, 16 May 2023 10:38:51 +0100 Subject: [PATCH] CLDC-2352 Infer uprn_known in 23/24 sales bulk upload (#1625) * feat: infer uprn_known * feat: add test * refactor: lint * feat: process postcode changes to clear la etc when uprn errors clear values * feat: revert previous (moved to CLDC-2357 instead) * feat: revert previous (moved to CLDC-2357 instead) --- .../bulk_upload/sales/year2023/row_parser.rb | 1 + .../sales/year2023/row_parser_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 11cd9f9a7..62598c5ad 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -823,6 +823,7 @@ private attributes["mortgageused"] = mortgageused attributes["uprn"] = field_19 + attributes["uprn_known"] = field_19.present? ? 1 : 0 attributes["address_line1"] = field_20 attributes["address_line2"] = field_21 attributes["town_or_city"] = field_22 diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index 8c5b899b9..3e6413be7 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -662,6 +662,24 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do end end + describe "#uprn_known" do + context "when uprn known" do + let(:attributes) { setup_section_params.merge({ field_19: "100023336956" }) } + + it "is correctly set" do + expect(parser.log.uprn_known).to be(1) + end + end + + context "when uprn not known" do + let(:attributes) { setup_section_params.merge({ field_19: nil }) } + + it "is correctly set" do + expect(parser.log.uprn_known).to be(0) + end + end + end + describe "#address_line1" do let(:attributes) { setup_section_params.merge({ field_20: "some street" }) }