This commit is contained in:
Brian Gough 2018-09-18 13:57:11 +01:00
parent 47a7d2eaa9
commit 02854274a7
2 changed files with 13 additions and 1 deletions

View file

@ -34,7 +34,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()

View file

@ -93,6 +93,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'