From 8c7ea67e9dba2d008e0f1ceda3a7ba88c5da71b9 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Tue, 10 Jan 2023 12:09:01 +0000 Subject: [PATCH] add #relatN fields to bulk upload --- .../bulk_upload/lettings/row_parser.rb | 28 +++++++++++++++ .../bulk_upload/lettings/row_parser_spec.rb | 35 ++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index 7dca3e2c7..676e5cfd7 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -261,6 +261,14 @@ private ethnic: %i[field_43], national: %i[field_44], + relat2: %i[field_28], + relat3: %i[field_29], + relat4: %i[field_30], + relat5: %i[field_31], + relat6: %i[field_32], + relat7: %i[field_33], + relat8: %i[field_34], + ecstat1: %i[field_35], ecstat2: %i[field_36], ecstat3: %i[field_37], @@ -412,6 +420,14 @@ private attributes["ethnic"] = field_43 attributes["national"] = field_44 + attributes["relat2"] = field_28 + attributes["relat3"] = field_29 + attributes["relat4"] = field_30 + attributes["relat5"] = field_31 + attributes["relat6"] = field_32 + attributes["relat7"] = field_33 + attributes["relat8"] = field_34 + attributes["ecstat1"] = field_35 attributes["ecstat2"] = field_36 attributes["ecstat3"] = field_37 @@ -421,6 +437,14 @@ private attributes["ecstat7"] = field_41 attributes["ecstat8"] = field_42 + attributes["details_known_2"] = details_known(2) + attributes["details_known_3"] = details_known(3) + attributes["details_known_4"] = details_known(4) + attributes["details_known_5"] = details_known(5) + attributes["details_known_6"] = details_known(6) + attributes["details_known_7"] = details_known(7) + attributes["details_known_8"] = details_known(8) + attributes["armedforces"] = field_45 attributes["leftreg"] = leftreg attributes["reservist"] = field_46 @@ -500,6 +524,10 @@ private end end + def details_known(person_n) + send("person_#{person_n}_present?") ? 0 : 1 + end + def hhmemb [ person_2_present?, diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index ca9b76e7a..a9de07261 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -78,7 +78,7 @@ RSpec.describe BulkUpload::Lettings::RowParser do field_16: "16", field_17: "14", field_18: "12", - field_19: "10", + field_19: "20", field_20: "F", field_21: "M", @@ -92,6 +92,14 @@ RSpec.describe BulkUpload::Lettings::RowParser do field_43: "17", field_44: "18", + field_28: "P", + field_29: "C", + field_30: "X", + field_31: "R", + field_32: "C", + field_33: "C", + field_34: "X", + field_35: "1", field_36: "2", field_37: "6", @@ -415,5 +423,30 @@ RSpec.describe BulkUpload::Lettings::RowParser do expect(parser.log.ecstat8).to eq(10) end end + + describe "#relatN fields" do + let(:attributes) do + { + bulk_upload:, + field_28: "P", + field_29: "C", + field_30: "X", + field_31: "R", + field_32: "P", + field_33: "C", + field_34: "X", + } + end + + it "sets value from correct mapping", aggregate_failures: true do + expect(parser.log.relat2).to eq("P") + expect(parser.log.relat3).to eq("C") + expect(parser.log.relat4).to eq("X") + expect(parser.log.relat5).to eq("R") + expect(parser.log.relat6).to eq("P") + expect(parser.log.relat7).to eq("C") + expect(parser.log.relat8).to eq("X") + end + end end end