mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 19:41:33 +02:00
adding a filter condition for adding an email (#15914)
* adding a filter condition for adding an email * fixing failing tests GitOrigin-RevId: 5276ad69229ab16b776da29150a103513e23d15a
This commit is contained in:
@@ -104,7 +104,7 @@ async function addEmailAddress(userId, newEmail, affiliationOptions, auditLog) {
|
||||
emails: { email: newEmail, createdAt: new Date(), reversedHostname },
|
||||
},
|
||||
}
|
||||
await updateUser(userId, update)
|
||||
await updateUser({ _id: userId, 'emails.email': { $ne: newEmail } }, update)
|
||||
} catch (error) {
|
||||
throw OError.tag(error, 'problem updating users emails')
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ describe('UserUpdater', function () {
|
||||
|
||||
it('adds the new email', function () {
|
||||
expect(this.db.users.updateOne).to.have.been.calledWith(
|
||||
{ _id: this.user._id },
|
||||
{ _id: this.user._id, 'emails.email': { $ne: this.newEmail } },
|
||||
{
|
||||
$push: {
|
||||
emails: sinon.match({ email: this.newEmail }),
|
||||
@@ -281,7 +281,7 @@ describe('UserUpdater', function () {
|
||||
.reverse()
|
||||
.join('')
|
||||
this.db.users.updateOne.should.have.been.calledWith(
|
||||
{ _id: this.user._id },
|
||||
{ _id: this.user._id, 'emails.email': { $ne: this.newEmail } },
|
||||
{
|
||||
$push: {
|
||||
emails: {
|
||||
|
||||
Reference in New Issue
Block a user