fix cc cleanup fixup for mixed case email addresses

Change-Id: Iaa433fc3679a90b0b6c6bb054b1fab5a052a14f2
Reviewed-on: https://gerrit.instructure.com/127380
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
Simon Williams 2017-09-26 10:32:06 -06:00
parent 234d5bd014
commit cf7e5dfc38
3 changed files with 11 additions and 1 deletions

View File

@ -31,7 +31,7 @@ module DataFixup::DeleteInvalidCommunicationChannels
end
r1.each do |id, user_id, path|
if scope.where(user_id: user_id, path: path.strip).exists?
if scope.by_path(path.strip).where(user_id: user_id).exists?
r2 << [id, user_id, path]
else
CommunicationChannel.where(id: id).update_all(path: path.strip)

View File

@ -43,4 +43,14 @@ describe DataFixup::DeleteInvalidCommunicationChannels do
DataFixup::DeleteInvalidCommunicationChannels.run
expect(CommunicationChannel.where(id: @channel.id).exists?).to be_falsey
end
it "deletes valid duplicate email with whitespace and mixed case" do
CommunicationChannel.where(id: @channel.id).update_all(path: " Valid@Example.com")
@channel2 = @user.communication_channels.create!(
path: "valid@example.com",
path_type: CommunicationChannel::TYPE_EMAIL
)
DataFixup::DeleteInvalidCommunicationChannels.run
expect(CommunicationChannel.where(id: @channel.id).exists?).to be_falsey
end
end