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?
|
if err?
|
||||||
logger.err {projectId, email}, "error checking if user exists"
|
logger.err {projectId, email}, "error checking if user exists"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
if !existingUser
|
if !existingUser?
|
||||||
logger.log {projectId, email}, "no existing user found, returning"
|
logger.log {projectId, email}, "no existing user found, returning"
|
||||||
return callback(null)
|
return callback(null)
|
||||||
ProjectGetter.getProject projectId, (err, project) ->
|
ProjectGetter.getProject projectId, {_id: 1, name: 1}, (err, project) ->
|
||||||
if err?
|
if err?
|
||||||
logger.err {projectId, email}, "error getting project"
|
logger.err {projectId, email}, "error getting project"
|
||||||
return callback(err)
|
return callback(err)
|
||||||
if !project
|
if !project?
|
||||||
logger.log {projectId}, "no project found while sending notification, returning"
|
logger.log {projectId}, "no project found while sending notification, returning"
|
||||||
return callback(null)
|
return callback(null)
|
||||||
NotificationsBuilder.projectInvite(invite, project, sendingUser, existingUser).create(callback)
|
NotificationsBuilder.projectInvite(invite, project, sendingUser, existingUser).create(callback)
|
||||||
|
@ -109,7 +109,7 @@ module.exports = CollaboratorsInviteController =
|
||||||
logger.err {projectId, token}, "error getting invite by token"
|
logger.err {projectId, token}, "error getting invite by token"
|
||||||
return next(err)
|
return next(err)
|
||||||
# check if invite is gone, or otherwise non-existent
|
# check if invite is gone, or otherwise non-existent
|
||||||
if !invite
|
if !invite?
|
||||||
logger.log {projectId, token}, "no invite found for this token"
|
logger.log {projectId, token}, "no invite found for this token"
|
||||||
return _renderInvalidPage()
|
return _renderInvalidPage()
|
||||||
# check the user who sent the invite exists
|
# check the user who sent the invite exists
|
||||||
|
@ -117,7 +117,7 @@ module.exports = CollaboratorsInviteController =
|
||||||
if err?
|
if err?
|
||||||
logger.err {err, projectId}, "error getting project owner"
|
logger.err {err, projectId}, "error getting project owner"
|
||||||
return next(err)
|
return next(err)
|
||||||
if !owner
|
if !owner?
|
||||||
logger.log {projectId}, "no project owner found"
|
logger.log {projectId}, "no project owner found"
|
||||||
return _renderInvalidPage()
|
return _renderInvalidPage()
|
||||||
# fetch the project name
|
# fetch the project name
|
||||||
|
@ -125,7 +125,7 @@ module.exports = CollaboratorsInviteController =
|
||||||
if err?
|
if err?
|
||||||
logger.err {err, projectId}, "error getting project"
|
logger.err {err, projectId}, "error getting project"
|
||||||
return next(err)
|
return next(err)
|
||||||
if !project
|
if !project?
|
||||||
logger.log {projectId}, "no project found"
|
logger.log {projectId}, "no project found"
|
||||||
return _renderInvalidPage()
|
return _renderInvalidPage()
|
||||||
# finally render the invite
|
# finally render the invite
|
||||||
|
|
|
@ -73,7 +73,7 @@ describe "CollaboratorsInviteController", ->
|
||||||
@fakeProject =
|
@fakeProject =
|
||||||
_id: @project_id
|
_id: @project_id
|
||||||
name: "some project"
|
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)}
|
@notification = {create: sinon.stub().callsArgWith(0, null)}
|
||||||
@NotificationsBuilder.projectInvite = sinon.stub().returns(@notification)
|
@NotificationsBuilder.projectInvite = sinon.stub().returns(@notification)
|
||||||
@call = (callback) =>
|
@call = (callback) =>
|
||||||
|
@ -109,7 +109,7 @@ describe "CollaboratorsInviteController", ->
|
||||||
describe 'when getProject produces an error', ->
|
describe 'when getProject produces an error', ->
|
||||||
|
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
@ProjectGetter.getProject.callsArgWith(1, new Error('woops'))
|
@ProjectGetter.getProject.callsArgWith(2, new Error('woops'))
|
||||||
|
|
||||||
it 'should produce an error', (done) ->
|
it 'should produce an error', (done) ->
|
||||||
@call (err) =>
|
@call (err) =>
|
||||||
|
|
Loading…
Reference in a new issue