mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Address feedback, add ?
checks where appropriate
This commit is contained in:
parent
e53394919f
commit
f92767f7b5
2 changed files with 8 additions and 8 deletions
|
@ -26,14 +26,14 @@ module.exports = CollaboratorsInviteController =
|
|||
if err?
|
||||
logger.err {projectId, email}, "error checking if user exists"
|
||||
return callback(err)
|
||||
if !existingUser
|
||||
if !existingUser?
|
||||
logger.log {projectId, email}, "no existing user found, returning"
|
||||
return callback(null)
|
||||
ProjectGetter.getProject projectId, (err, project) ->
|
||||
ProjectGetter.getProject projectId, {_id: 1, name: 1}, (err, project) ->
|
||||
if err?
|
||||
logger.err {projectId, email}, "error getting project"
|
||||
return callback(err)
|
||||
if !project
|
||||
if !project?
|
||||
logger.log {projectId}, "no project found while sending notification, returning"
|
||||
return callback(null)
|
||||
NotificationsBuilder.projectInvite(invite, project, sendingUser, existingUser).create(callback)
|
||||
|
@ -109,7 +109,7 @@ module.exports = CollaboratorsInviteController =
|
|||
logger.err {projectId, token}, "error getting invite by token"
|
||||
return next(err)
|
||||
# check if invite is gone, or otherwise non-existent
|
||||
if !invite
|
||||
if !invite?
|
||||
logger.log {projectId, token}, "no invite found for this token"
|
||||
return _renderInvalidPage()
|
||||
# check the user who sent the invite exists
|
||||
|
@ -117,7 +117,7 @@ module.exports = CollaboratorsInviteController =
|
|||
if err?
|
||||
logger.err {err, projectId}, "error getting project owner"
|
||||
return next(err)
|
||||
if !owner
|
||||
if !owner?
|
||||
logger.log {projectId}, "no project owner found"
|
||||
return _renderInvalidPage()
|
||||
# fetch the project name
|
||||
|
@ -125,7 +125,7 @@ module.exports = CollaboratorsInviteController =
|
|||
if err?
|
||||
logger.err {err, projectId}, "error getting project"
|
||||
return next(err)
|
||||
if !project
|
||||
if !project?
|
||||
logger.log {projectId}, "no project found"
|
||||
return _renderInvalidPage()
|
||||
# finally render the invite
|
||||
|
|
|
@ -73,7 +73,7 @@ describe "CollaboratorsInviteController", ->
|
|||
@fakeProject =
|
||||
_id: @project_id
|
||||
name: "some project"
|
||||
@ProjectGetter.getProject = sinon.stub().callsArgWith(1, null, @fakeProject)
|
||||
@ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, @fakeProject)
|
||||
@notification = {create: sinon.stub().callsArgWith(0, null)}
|
||||
@NotificationsBuilder.projectInvite = sinon.stub().returns(@notification)
|
||||
@call = (callback) =>
|
||||
|
@ -109,7 +109,7 @@ describe "CollaboratorsInviteController", ->
|
|||
describe 'when getProject produces an error', ->
|
||||
|
||||
beforeEach ->
|
||||
@ProjectGetter.getProject.callsArgWith(1, new Error('woops'))
|
||||
@ProjectGetter.getProject.callsArgWith(2, new Error('woops'))
|
||||
|
||||
it 'should produce an error', (done) ->
|
||||
@call (err) =>
|
||||
|
|
Loading…
Reference in a new issue