From 4a0d6ccb7ec66fe50261bf3565d212d11210184a Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 13 Feb 2023 15:39:02 +0000 Subject: [PATCH] bulk upload considers housing needs fields --- .../bulk_upload/lettings/row_parser.rb | 18 ++++++- .../bulk_upload/lettings/row_parser_spec.rb | 54 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index 9d5604587..f5f38a4b2 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -552,6 +552,8 @@ private attributes["preg_occ"] = field_47 attributes["housingneeds"] = housingneeds + attributes["housingneeds_type"] = housingneeds_type + attributes["housingneeds_other"] = housingneeds_other attributes["illness"] = field_118 @@ -808,7 +810,7 @@ private def housingneeds if field_59 == 1 - 1 + 2 elsif field_60 == 1 3 else @@ -816,6 +818,20 @@ private end end + def housingneeds_type + if field_55 == 1 + 0 + elsif field_56 == 1 + 1 + elsif field_57 == 1 + 2 + end + end + + def housingneeds_other + return 1 if field_58 == 1 + end + def ethnic_group_from_ethnic return nil if field_43.blank? diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index 8f609838c..8a46b828a 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -894,6 +894,60 @@ RSpec.describe BulkUpload::Lettings::RowParser do end end end + + describe "#housingneeds" do + context "when no disabled needs" do + let(:attributes) { { bulk_upload:, field_59: "1" } } + + it "sets to 2" do + expect(parser.log.housingneeds).to eq(2) + end + end + + context "when dont know about disabled needs" do + let(:attributes) { { bulk_upload:, field_60: "1" } } + + it "sets to 3" do + expect(parser.log.housingneeds).to eq(3) + end + end + end + + describe "#housingneeds_type" do + context "when field_55 is 1" do + let(:attributes) { { bulk_upload:, field_55: "1" } } + + it "set to 0" do + expect(parser.log.housingneeds_type).to eq(0) + end + end + + context "when field_56 is 1" do + let(:attributes) { { bulk_upload:, field_56: "1" } } + + it "set to 1" do + expect(parser.log.housingneeds_type).to eq(1) + end + end + + context "when field_57 is 1" do + let(:attributes) { { bulk_upload:, field_57: "1" } } + + it "set to 2" do + expect(parser.log.housingneeds_type).to eq(2) + end + end + end + + describe "#housingneeds_other" do + context "when field_58 is 1" do + let(:attributes) { { bulk_upload:, field_58: "1" } } + + it "sets to 1" do + expect(parser.log.housingneeds_other).to eq(1) + end + end + end end describe "#start_date" do