From 7bfe3f4d7590fad0cc5c38b2e08c7f4dc7dcd47a Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Fri, 16 Jun 2023 15:28:35 +0100 Subject: [PATCH] CLDC-2447 Bulk upload 23-24 lettings net income known bug (#1695) * feat: fix bug * feat: update tests * feat: test ALL possibilities --- .../lettings/year2023/row_parser.rb | 2 -- .../lettings/year2022/row_parser_spec.rb | 32 +++++++++++++++++-- .../lettings/year2023/row_parser_spec.rb | 24 ++++++++++++-- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 225c45b4f..0912b02e4 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -1442,8 +1442,6 @@ private when 2 1 when 3 - 1 - when 4 2 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 05120713d..365771bb6 100644 --- a/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb @@ -1295,10 +1295,36 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do end describe "#net_income_known" do - let(:attributes) { { bulk_upload:, field_51: "1" } } + context "when 1" do + let(:attributes) { { bulk_upload:, field_51: "1" } } - it "sets value from correct mapping" do - expect(parser.log.net_income_known).to eq(0) + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(0) + end + end + + context "when 2" do + let(:attributes) { { bulk_upload:, field_51: "2" } } + + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(1) + end + end + + context "when 3" do + let(:attributes) { { bulk_upload:, field_51: "3" } } + + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(1) + end + end + + context "when 4" do + let(:attributes) { { bulk_upload:, field_51: "4" } } + + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(2) + end end end 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 8586a470c..5bb6e8958 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -1365,10 +1365,28 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end describe "#net_income_known" do - let(:attributes) { { bulk_upload:, field_120: "1" } } + context "when 1" do + let(:attributes) { { bulk_upload:, field_120: "1" } } - it "sets value from correct mapping" do - expect(parser.log.net_income_known).to eq(0) + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(0) + end + end + + context "when 2" do + let(:attributes) { { bulk_upload:, field_120: "2" } } + + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(1) + end + end + + context "when 3" do + let(:attributes) { { bulk_upload:, field_120: "3" } } + + it "sets value from correct mapping" do + expect(parser.log.net_income_known).to eq(2) + end end end