mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #933 from sharelatex/bg-avoid-exception-for-no-emails
fix exception when user has no emails field
This commit is contained in:
commit
b377b89447
2 changed files with 13 additions and 1 deletions
|
@ -35,7 +35,7 @@ module.exports = UserGetter =
|
|||
|
||||
getUserAffiliations userId, (error, affiliationsData) ->
|
||||
return callback error if error?
|
||||
callback null, decorateFullEmails(user.email, user.emails, affiliationsData)
|
||||
callback null, decorateFullEmails(user.email, user.emails or [], affiliationsData)
|
||||
|
||||
getUserByMainEmail: (email, projection, callback = (error, user) ->) ->
|
||||
email = email.trim()
|
||||
|
|
|
@ -98,6 +98,18 @@ describe "UserGetter", ->
|
|||
]
|
||||
done()
|
||||
|
||||
it "should get user when it has no emails field", (done)->
|
||||
@fakeUser =
|
||||
_id: '12390i'
|
||||
email: 'email2@foo.bar'
|
||||
@UserGetter.getUser = sinon.stub().callsArgWith(2, null, @fakeUser)
|
||||
projection = email: 1, emails: 1
|
||||
@UserGetter.getUserFullEmails @fakeUser._id, (error, fullEmails) =>
|
||||
@UserGetter.getUser.called.should.equal true
|
||||
@UserGetter.getUser.calledWith(@fakeUser._id, projection).should.equal true
|
||||
assert.deepEqual fullEmails, []
|
||||
done()
|
||||
|
||||
describe "getUserbyMainEmail", ->
|
||||
it "query user by main email", (done)->
|
||||
email = 'hello@world.com'
|
||||
|
|
Loading…
Reference in a new issue