Browse Source

Set created_by on BU

CLDC-3345-save-created-by-values
Kat 11 months ago
parent
commit
51758f0bba
  1. 1
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  2. 1
      app/services/bulk_upload/lettings/year2024/row_parser.rb
  3. 1
      app/services/bulk_upload/sales/year2023/row_parser.rb
  4. 1
      app/services/bulk_upload/sales/year2024/row_parser.rb
  5. 18
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  6. 18
      spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb
  7. 18
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb
  8. 18
      spec/services/bulk_upload/sales/year2024/row_parser_spec.rb

1
app/services/bulk_upload/lettings/year2023/row_parser.rb

@ -1089,6 +1089,7 @@ private
attributes["scheme"] = scheme attributes["scheme"] = scheme
attributes["location"] = location attributes["location"] = location
attributes["assigned_to"] = assigned_to || bulk_upload.user attributes["assigned_to"] = assigned_to || bulk_upload.user
attributes["created_by"] = bulk_upload.user
attributes["needstype"] = field_4 attributes["needstype"] = field_4
attributes["rent_type"] = rent_type attributes["rent_type"] = rent_type
attributes["startdate"] = startdate attributes["startdate"] = startdate

1
app/services/bulk_upload/lettings/year2024/row_parser.rb

@ -1114,6 +1114,7 @@ private
attributes["scheme"] = scheme attributes["scheme"] = scheme
attributes["location"] = location attributes["location"] = location
attributes["assigned_to"] = assigned_to || bulk_upload.user attributes["assigned_to"] = assigned_to || bulk_upload.user
attributes["created_by"] = bulk_upload.user
attributes["needstype"] = field_4 attributes["needstype"] = field_4
attributes["rent_type"] = field_11 attributes["rent_type"] = field_11
attributes["startdate"] = startdate attributes["startdate"] = startdate

1
app/services/bulk_upload/sales/year2023/row_parser.rb

@ -897,6 +897,7 @@ private
attributes["owning_organisation"] = owning_organisation attributes["owning_organisation"] = owning_organisation
attributes["managing_organisation"] = managing_organisation attributes["managing_organisation"] = managing_organisation
attributes["assigned_to"] = assigned_to || bulk_upload.user attributes["assigned_to"] = assigned_to || bulk_upload.user
attributes["created_by"] = bulk_upload.user
attributes["hhregres"] = field_73 attributes["hhregres"] = field_73
attributes["hhregresstill"] = field_74 attributes["hhregresstill"] = field_74
attributes["armedforcesspouse"] = field_75 attributes["armedforcesspouse"] = field_75

1
app/services/bulk_upload/sales/year2024/row_parser.rb

@ -911,6 +911,7 @@ private
attributes["owning_organisation"] = owning_organisation attributes["owning_organisation"] = owning_organisation
attributes["managing_organisation"] = managing_organisation attributes["managing_organisation"] = managing_organisation
attributes["assigned_to"] = assigned_to || bulk_upload.user attributes["assigned_to"] = assigned_to || bulk_upload.user
attributes["created_by"] = bulk_upload.user
attributes["hhregres"] = field_72 attributes["hhregres"] = field_72
attributes["hhregresstill"] = field_73 attributes["hhregresstill"] = field_73
attributes["armedforcesspouse"] = field_74 attributes["armedforcesspouse"] = field_74

18
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 it "is permitted" do
expect(parser.errors[:field_3]).to be_blank expect(parser.errors[:field_3]).to be_blank
end 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 end
context "when user could not be found" do context "when user could not be found" do
@ -748,7 +756,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
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(: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 } } 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 it "is permitted" do
expect(parser.errors[:field_3]).to be_blank expect(parser.errors[:field_3]).to be_blank
end 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 end
context "when email matches other than casing" do context "when email matches other than casing" do

18
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 it "is permitted" do
expect(parser.errors[:field_3]).to be_blank expect(parser.errors[:field_3]).to be_blank
end 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 end
context "when user could not be found" do context "when user could not be found" do
@ -851,7 +859,7 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do
end end
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(: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 } } 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 it "is permitted" do
expect(parser.errors[:field_3]).to be_blank expect(parser.errors[:field_3]).to be_blank
end 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 end
context "when email matches other than casing" do context "when email matches other than casing" do

18
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 it "is permitted" do
expect(parser.errors[:field_2]).to be_blank expect(parser.errors[:field_2]).to be_blank
end 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 end
context "when user could not be found" do context "when user could not be found" do
@ -524,7 +532,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
end end
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(:other_user) { create(:user, organisation: owning_org) }
let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_2: other_user.email } } 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 it "is permitted" do
expect(parser.errors[:field_2]).to be_blank expect(parser.errors[:field_2]).to be_blank
end 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 end
context "when email matches other than casing" do context "when email matches other than casing" do

18
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 it "is permitted" do
expect(parser.errors[:field_3]).to be_blank expect(parser.errors[:field_3]).to be_blank
end 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 end
context "when user could not be found" do context "when user could not be found" do
@ -555,7 +563,7 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do
end end
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(:other_user) { create(:user, organisation: owning_org) }
let(:attributes) { { bulk_upload:, field_1: owning_org.old_visible_id, field_3: other_user.email } } 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 it "is permitted" do
expect(parser.errors[:field_3]).to be_blank expect(parser.errors[:field_3]).to be_blank
end 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 end
context "when email matches other than casing" do context "when email matches other than casing" do

Loading…
Cancel
Save