diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index e6421b2e1..abeb638a0 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/app/services/bulk_upload/lettings/row_parser.rb @@ -324,6 +324,17 @@ private unitletas: %i[field_105], rsnvac: %i[field_106], sheltered: %i[field_117], + + illness_type_1: %i[field_119], + illness_type_2: %i[field_120], + illness_type_3: %i[field_121], + illness_type_4: %i[field_122], + illness_type_5: %i[field_123], + illness_type_6: %i[field_124], + illness_type_7: %i[field_125], + illness_type_8: %i[field_126], + illness_type_9: %i[field_127], + illness_type_10: %i[field_128], } end @@ -502,6 +513,17 @@ private attributes["rsnvac"] = field_106 attributes["sheltered"] = field_117 + attributes["illness_type_1"] = field_119 + attributes["illness_type_2"] = field_120 + attributes["illness_type_3"] = field_121 + attributes["illness_type_4"] = field_122 + attributes["illness_type_5"] = field_123 + attributes["illness_type_6"] = field_124 + attributes["illness_type_7"] = field_125 + attributes["illness_type_8"] = field_126 + attributes["illness_type_9"] = field_127 + attributes["illness_type_10"] = field_128 + attributes end diff --git a/spec/services/bulk_upload/lettings/row_parser_spec.rb b/spec/services/bulk_upload/lettings/row_parser_spec.rb index 077b24e0c..bb6f7297d 100644 --- a/spec/services/bulk_upload/lettings/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/row_parser_spec.rb @@ -482,5 +482,40 @@ RSpec.describe BulkUpload::Lettings::RowParser do expect(parser.log.sheltered).to eq(1) end end + + describe "illness fields" do + mapping = [ + { attribute: :illness_type_1, field: :field_119 }, + { attribute: :illness_type_2, field: :field_120 }, + { attribute: :illness_type_3, field: :field_121 }, + { attribute: :illness_type_4, field: :field_122 }, + { attribute: :illness_type_5, field: :field_123 }, + { attribute: :illness_type_6, field: :field_124 }, + { attribute: :illness_type_7, field: :field_125 }, + { attribute: :illness_type_8, field: :field_126 }, + { attribute: :illness_type_9, field: :field_127 }, + { attribute: :illness_type_10, field: :field_128 }, + ] + + mapping.each do |hash| + describe "##{hash[:attribute]}" do + context "when yes" do + let(:attributes) { { bulk_upload:, hash[:field] => "1" } } + + it "sets value from correct mapping" do + expect(parser.log.public_send(hash[:attribute])).to eq(1) + end + end + + context "when no" do + let(:attributes) { { bulk_upload:, hash[:field] => "" } } + + it "sets value from correct mapping" do + expect(parser.log.public_send(hash[:attribute])).to be_nil + end + end + end + end + end end end