From 210ae5d22741a7aae63fe1ca732d956a2d7eb8bd Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 25 May 2023 07:54:15 +0100 Subject: [PATCH] Correctly set hhregres and hhregresstill (#1660) --- .../bulk_upload/sales/year2023/row_parser.rb | 23 +++---------------- .../sales/year2023/row_parser_spec.rb | 8 +++++++ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 623a356d2..b5185f7a0 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -702,7 +702,7 @@ private owning_organisation_id: %i[field_1], created_by: %i[field_2], hhregres: %i[field_73], - hhregresstill: %i[field_73], + hhregresstill: %i[field_74], armedforcesspouse: %i[field_75], mortgagelender: %i[field_107 field_121 field_130], @@ -868,8 +868,8 @@ private attributes["owning_organisation"] = owning_organisation attributes["created_by"] = created_by || bulk_upload.user - attributes["hhregres"] = hhregres - attributes["hhregresstill"] = hhregresstill + attributes["hhregres"] = field_73 + attributes["hhregresstill"] = field_74 attributes["armedforcesspouse"] = field_75 attributes["mortgagelender"] = mortgagelender @@ -912,8 +912,6 @@ private attributes["buy2living"] = field_71 attributes["prevtenbuy2"] = prevtenbuy2 - attributes["hhregresstill"] = field_74 - attributes["prevshared"] = field_85 attributes["staircasesale"] = field_90 @@ -1088,21 +1086,6 @@ private @created_by ||= User.find_by(email: field_2) end - def hhregres - case field_73 - when 3 then 3 - when 4, 5, 6 then 1 - when 7 then 7 - when 8 then 8 - end - end - - def hhregresstill - return unless hhregres == 1 - - field_73 - end - def previous_la_known field_66.present? ? 1 : 0 end diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index e9a4e723e..b2de40ad4 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -964,6 +964,14 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do end end + describe "#hhregres" do + let(:attributes) { setup_section_params.merge({ field_73: "1" }) } + + it "is correctly set" do + expect(parser.log.hhregres).to be(1) + end + end + describe "#hhregresstill" do let(:attributes) { setup_section_params.merge({ field_74: "4" }) }