Browse Source

CLDC-2982 Make bulk upload user emails case insensitive (#2017)

* feat: match email regardless of casing in bulk upload

* feat: allow null emails

* feat: set encoding by bom for file IO before parsing

* Revert "feat: set encoding by bom for file IO before parsing"

This reverts commit 03d2d17e7b.
pull/2023/head v0.3.76
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
f3177f612d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/services/bulk_upload/lettings/year2022/row_parser.rb
  2. 2
      app/services/bulk_upload/lettings/year2023/row_parser.rb
  3. 2
      app/services/bulk_upload/sales/year2022/row_parser.rb
  4. 2
      app/services/bulk_upload/sales/year2023/row_parser.rb
  5. 10
      spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb
  6. 10
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  7. 10
      spec/services/bulk_upload/sales/year2022/row_parser_spec.rb
  8. 10
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

2
app/services/bulk_upload/lettings/year2022/row_parser.rb

@ -511,7 +511,7 @@ private
end end
def created_by def created_by
@created_by ||= User.find_by(email: field_112) @created_by ||= User.where("lower(email) = ?", field_112&.downcase).first
end end
def duplicate_check_fields def duplicate_check_fields

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

@ -540,7 +540,7 @@ private
end end
def created_by def created_by
@created_by ||= User.find_by(email: field_3) @created_by ||= User.where("lower(email) = ?", field_3&.downcase).first
end end
def validate_uprn_exists_if_any_key_address_fields_are_blank def validate_uprn_exists_if_any_key_address_fields_are_blank

2
app/services/bulk_upload/sales/year2022/row_parser.rb

@ -934,7 +934,7 @@ private
end end
def created_by def created_by
@created_by ||= User.find_by(email: field_93) @created_by ||= User.where("lower(email) = ?", field_93&.downcase).first
end end
def hhregres def hhregres

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

@ -1112,7 +1112,7 @@ private
end end
def created_by def created_by
@created_by ||= User.find_by(email: field_2) @created_by ||= User.where("lower(email) = ?", field_2&.downcase).first
end end
def previous_la_known def previous_la_known

10
spec/services/bulk_upload/lettings/year2022/row_parser_spec.rb

@ -1128,6 +1128,16 @@ RSpec.describe BulkUpload::Lettings::Year2022::RowParser do
end end
end end
context "when email matches other than casing" do
let(:other_user) { create(:user, organisation: owning_org) }
let(:attributes) { { bulk_upload:, field_111: owning_org.old_visible_id, field_112: other_user.email.upcase!, field_113: managing_org.old_visible_id } }
it "is permitted" do
expect(parser.errors[:field_112]).to be_blank
end
end
context "when an user part of managing org" do context "when an user part of managing org" do
let(:other_user) { create(:user, organisation: managing_org) } let(:other_user) { create(:user, organisation: managing_org) }

10
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -753,6 +753,16 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
end end
end end
context "when email matches other than casing" 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.upcase!, field_2: managing_org.old_visible_id } }
it "is permitted" do
expect(parser.errors[:field_3]).to be_blank
end
end
context "when an user part of managing org" do context "when an user part of managing org" do
let(:other_user) { create(:user, organisation: managing_org) } let(:other_user) { create(:user, organisation: managing_org) }

10
spec/services/bulk_upload/sales/year2022/row_parser_spec.rb

@ -510,6 +510,16 @@ RSpec.describe BulkUpload::Sales::Year2022::RowParser do
expect(parser.errors[:field_93]).to be_blank expect(parser.errors[:field_93]).to be_blank
end end
end end
context "when email matches other than casing" do
let(:other_user) { create(:user, organisation: owning_org) }
let(:attributes) { { bulk_upload:, field_92: owning_org.old_visible_id, field_93: other_user.email.upcase! } }
it "is permitted" do
expect(parser.errors[:field_93]).to be_blank
end
end
end end
[ [

10
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -459,6 +459,16 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
expect(parser.errors[:field_2]).to be_blank expect(parser.errors[:field_2]).to be_blank
end end
end end
context "when email matches other than casing" 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.upcase! } }
it "is permitted" do
expect(parser.errors[:field_2]).to be_blank
end
end
end end
describe "fields 3, 4, 5 => saledate" do describe "fields 3, 4, 5 => saledate" do

Loading…
Cancel
Save