From 8698497b123858a3ca51e413a0a27f5b82cf73d4 Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Tue, 4 Apr 2023 12:33:55 +0100 Subject: [PATCH] test: add tests for UPRN/address fields --- .../lettings/year2023/row_parser_spec.rb | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index a94eaac64..1e0ced86a 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -810,6 +810,46 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do expect(parser.errors[:field_18]).to be_present end end + + context "when neither UPRN nor address given" do + let(:attributes) do + { + bulk_upload:, + field_1: "1", + } + end + + it "adds an appropriate error" do + expect(parser.errors[:field_18]).to eql(["You must answer UPRN known"]) + end + end + + context "when UPRN is given but address is not" do + let(:attributes) do + { + bulk_upload:, + field_18: "123456789012", + } + end + + it "doesn't add an error" do + expect(parser.errors[:field_18]).to be_empty + end + end + + context "when address is given but UPRN is not" do + let(:attributes) do + { + bulk_upload:, + field_19: "1 Example Rd", + field_21: "Example Town/City", + } + end + + it "doesn't add an error" do + expect(parser.errors[:field_18]).to be_empty + end + end end describe "#field_26" do # unitletas