From 2621da215bea6de46bae191ba9ac4cd67b3da255 Mon Sep 17 00:00:00 2001 From: Mark Isaac Date: Mon, 7 Oct 2024 14:58:52 +0100 Subject: [PATCH] update build_printable_address to send lines 1 - 5 only to PrintableAddress object --add address for unit tests --bump version --- lib/postman_paf/rules/address_builder.rb | 2 +- lib/postman_paf/version.rb | 2 +- spec/fixtures/addresses.json | 33 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/postman_paf/rules/address_builder.rb b/lib/postman_paf/rules/address_builder.rb index 76d442e..9abdd99 100644 --- a/lib/postman_paf/rules/address_builder.rb +++ b/lib/postman_paf/rules/address_builder.rb @@ -15,7 +15,7 @@ def self.build_printable_address(paf_address:, lines:) lines.each_with_index do |line, index| line_number = index + 1 line = line.to_s if line.is_a?(Integer) - printable_address.send("line#{line_number}=", line) unless line_number.eql?(6) || line_number.eql?(7) + printable_address.send("line#{line_number}=", line) if line_number >= 1 && line_number <= 5 end printable_address.postcode = paf_address[POSTCODE].slice(0..7) diff --git a/lib/postman_paf/version.rb b/lib/postman_paf/version.rb index 0534d21..b9f7d71 100644 --- a/lib/postman_paf/version.rb +++ b/lib/postman_paf/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module PostmanPAF - VERSION = '0.4.1' + VERSION = '0.4.2' end diff --git a/spec/fixtures/addresses.json b/spec/fixtures/addresses.json index 7bce16c..7f5dd30 100644 --- a/spec/fixtures/addresses.json +++ b/spec/fixtures/addresses.json @@ -2988,6 +2988,39 @@ "dps": "1A" } }, + "All Expected Elements": { + "paf": { + "uprn": "111111", + "udprn": "1111111", + "poBoxNumber": "dummy_poBoxNumber", + "organisationName": "dummy organisationName", + "departmentName": "dummy departmentName", + "subBuildingName": "dummy subBuildingName", + "buildingName": "MAIN BUILDING", + "buildingNumber": "11", + "dependentThoroughfareName": "LONG VIEW ROAD", + "thoroughfareName": "dummy thoroughfareName", + "doubleDependentLocality": "dummy doubleDependentLocality", + "dependentLocality": "MORRISTON", + "postTown": "SWANSEA", + "postcode": "SA99 1AA", + "dps": "1A", + "mailsort": "dummy-mailsort", + "language": "EN", + "country": "UNITED KINGDOM" + }, + "printable": { + "line1": "dummy organisationName", + "line2": "dummy departmentName", + "line3": "PO BOX dummy_poBoxNumber", + "line4": "dummy subBuildingName", + "line5": "SWANSEA", + "postcode": "SA99 1AA", + "country": "UNITED KINGDOM", + "language": "EN", + "dps": "1A" + } + }, "Exception i Sub Building Name": { "paf": { "poBoxNumber": null,