From 51758f0bba22fa66409baaf07027c7924a9562ad Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 8 Apr 2024 09:38:19 +0100 Subject: [PATCH] Set created_by on BU --- .../lettings/year2023/row_parser.rb | 1 + .../lettings/year2024/row_parser.rb | 1 + .../bulk_upload/sales/year2023/row_parser.rb | 1 + .../bulk_upload/sales/year2024/row_parser.rb | 1 + .../lettings/year2023/row_parser_spec.rb | 18 +++++++++++++++++- .../lettings/year2024/row_parser_spec.rb | 18 +++++++++++++++++- .../sales/year2023/row_parser_spec.rb | 18 +++++++++++++++++- .../sales/year2024/row_parser_spec.rb | 18 +++++++++++++++++- 8 files changed, 72 insertions(+), 4 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index f46337d39..faf8b9ee8 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -1089,6 +1089,7 @@ private attributes["scheme"] = scheme attributes["location"] = location attributes["assigned_to"] = assigned_to || bulk_upload.user + attributes["created_by"] = bulk_upload.user attributes["needstype"] = field_4 attributes["rent_type"] = rent_type attributes["startdate"] = startdate diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 9d9389c2c..47ad36186 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -1114,6 +1114,7 @@ private attributes["scheme"] = scheme attributes["location"] = location attributes["assigned_to"] = assigned_to || bulk_upload.user + attributes["created_by"] = bulk_upload.user attributes["needstype"] = field_4 attributes["rent_type"] = field_11 attributes["startdate"] = startdate diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 7b76546b0..819ea3618 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -897,6 +897,7 @@ private attributes["owning_organisation"] = owning_organisation attributes["managing_organisation"] = managing_organisation attributes["assigned_to"] = assigned_to || bulk_upload.user + attributes["created_by"] = bulk_upload.user attributes["hhregres"] = field_73 attributes["hhregresstill"] = field_74 attributes["armedforcesspouse"] = field_75 diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 0b0640588..e5715b3bc 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -911,6 +911,7 @@ private attributes["owning_organisation"] = owning_organisation attributes["managing_organisation"] = managing_organisation attributes["assigned_to"] = assigned_to || bulk_upload.user + attributes["created_by"] = bulk_upload.user attributes["hhregres"] = field_72 attributes["hhregresstill"] = field_73 attributes["armedforcesspouse"] = field_74 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 939d21e3f..c85c44530 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -724,6 +724,14 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do it "is permitted" do expect(parser.errors[:field_3]).to be_blank end + + it "sets assigned to to bulk upload user" do + expect(parser.log.assigned_to).to eq(bulk_upload.user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when user could not be found" do @@ -748,7 +756,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end - context "when an user part of owning org" do + context "when a user part of owning org" do let(:other_user) { create(:user, organisation: owning_org) } let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_3: other_user.email, field_2: managing_org.old_visible_id } } @@ -756,6 +764,14 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do it "is permitted" do expect(parser.errors[:field_3]).to be_blank end + + it "sets assigned to to the user" do + expect(parser.log.assigned_to).to eq(other_user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when email matches other than casing" do diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index 4c6e8219e..323a335e5 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -827,6 +827,14 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do it "is permitted" do expect(parser.errors[:field_3]).to be_blank end + + it "sets assigned to to bulk upload user" do + expect(parser.log.assigned_to).to eq(bulk_upload.user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when user could not be found" do @@ -851,7 +859,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end - context "when an user part of owning org" do + context "when a user part of owning org" do let(:other_user) { create(:user, organisation: owning_org) } let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_3: other_user.email, field_2: managing_org.old_visible_id } } @@ -859,6 +867,14 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do it "is permitted" do expect(parser.errors[:field_3]).to be_blank end + + it "sets assigned to to the user" do + expect(parser.log.assigned_to).to eq(other_user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when email matches other than casing" do 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 5f474a7c5..02131381f 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -500,6 +500,14 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do it "is permitted" do expect(parser.errors[:field_2]).to be_blank end + + it "sets assigned to to bulk upload user" do + expect(parser.log.assigned_to).to eq(bulk_upload.user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when user could not be found" do @@ -524,7 +532,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do end end - context "when an user part of owning org" do + context "when a user part of owning org" do let(:other_user) { create(:user, organisation: owning_org) } let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_2: other_user.email } } @@ -532,6 +540,14 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do it "is permitted" do expect(parser.errors[:field_2]).to be_blank end + + it "sets assigned to to the user" do + expect(parser.log.assigned_to).to eq(other_user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when email matches other than casing" do diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 934b75fa9..01206ff12 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -531,6 +531,14 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "is permitted" do expect(parser.errors[:field_3]).to be_blank end + + it "sets assigned to to bulk upload user" do + expect(parser.log.assigned_to).to eq(bulk_upload.user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when user could not be found" do @@ -555,7 +563,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do end end - context "when an user part of owning org" do + context "when a user part of owning org" do let(:other_user) { create(:user, organisation: owning_org) } let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_3: other_user.email } } @@ -563,6 +571,14 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "is permitted" do expect(parser.errors[:field_3]).to be_blank end + + it "sets assigned to to the user" do + expect(parser.log.assigned_to).to eq(other_user) + end + + it "sets created by to bulk upload user" do + expect(parser.log.created_by).to eq(bulk_upload.user) + end end context "when email matches other than casing" do