From 3b0a6064f2c639afdd7781ec503f50791f1329ac Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 21 Mar 2024 10:07:54 +0000 Subject: [PATCH] feat: add tests --- .../lettings/year2024/row_parser_spec.rb | 17 +++++++++++++++++ .../sales/year2024/row_parser_spec.rb | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index f99052d99..2301b6da6 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -1521,6 +1521,23 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end + describe "address fields" do + context "when no address can be found" do + before do + stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/) + .to_return(status: 200, body: nil, headers: {}) + end + + let(:attributes) { setup_section_params.merge({ field_16: nil, field_17: "address line 1", field_19: "town or city" }) } + + it "adds an appropriate error" do + %i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field| + expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."]) + end + end + end + end + describe "#field_25" do # unitletas context "when no longer a valid option from previous year" do let(:attributes) { setup_section_params.merge({ field_25: "4" }) } diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index c1014ecc3..2679b1a8b 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -886,6 +886,23 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do end end + describe "address fields" do + context "when no address can be found" do + before do + stub_request(:get, /api\.os\.uk\/search\/places\/v1\/find/) + .to_return(status: 200, body: nil, headers: {}) + end + + let(:attributes) { setup_section_params.merge({ field_22: nil, field_23: "address line 1", field_25: "town or city" }) } + + it "adds an appropriate error" do + %i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field| + expect(parser.errors[field]).to eql(["We could not find this address. Check the address data in your CSV file is correct and complete, or select the correct address using the CORE site."]) + end + end + end + end + describe "#field_18" do # data protection let(:attributes) { setup_section_params.merge({ field_18: nil }) }