From ab33b181fcaecba47508f3fdd537024ab534f292 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Mon, 3 Jul 2023 17:24:37 +0100 Subject: [PATCH] CLDC-2499 Fix housingneeds_type bug (#1746) * feat: set none of listed options for housingneeds_type in bu parsers * feat: add tests --- app/services/bulk_upload/lettings/year2022/row_parser.rb | 2 ++ app/services/bulk_upload/lettings/year2023/row_parser.rb | 2 ++ .../bulk_upload/lettings/year2022/row_parser_spec.rb | 9 +++++++++ .../bulk_upload/lettings/year2023/row_parser_spec.rb | 9 +++++++++ 4 files changed, 22 insertions(+) diff --git a/app/services/bulk_upload/lettings/year2022/row_parser.rb b/app/services/bulk_upload/lettings/year2022/row_parser.rb index b9aa66724..5e3211f9e 100644 --- a/app/services/bulk_upload/lettings/year2022/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2022/row_parser.rb @@ -1461,6 +1461,8 @@ private 1 elsif field_57 == 1 2 + else + 3 end end diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index f7de76030..e77c61405 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -1403,6 +1403,8 @@ private 1 elsif field_85 == 1 2 + else + 3 end end diff --git a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb index 9efa4c5a0..151b080b8 100644 --- a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb @@ -1728,6 +1728,15 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do end end + context "when housingneeds are not given" do + let(:attributes) { { bulk_upload:, field_55: nil, field_56: nil, field_57: nil, field_59: nil } } + + it "sets correct housingneeds" do + expect(parser.log.housingneeds).to eq(1) + expect(parser.log.housingneeds_type).to eq(3) + end + end + context "when housingneeds a and b are selected" do let(:attributes) { { bulk_upload:, field_55: "1", field_56: "1" } } 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 f3a17ac44..7b3ac949b 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -1790,6 +1790,15 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + context "when housingneeds are not given" do + let(:attributes) { { bulk_upload:, field_83: nil, field_84: nil, field_85: nil, field_87: nil } } + + it "sets correct housingneeds" do + expect(parser.log.housingneeds).to eq(1) + expect(parser.log.housingneeds_type).to eq(3) + end + end + context "when housingneeds a and b are selected" do let(:attributes) { { bulk_upload:, field_83: "1", field_84: "1" } }