From 882e28a8110509c1b6a70ac14ef5f1ed6bb5d42f Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 30 Jun 2016 14:30:04 +0100 Subject: [PATCH] Don't choke on null projects --- .../Features/Collaborators/CollaboratorsHandler.coffee | 1 + .../coffee/Collaborators/CollaboratorsHandlerTests.coffee | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee index 5f2580497d..81557fea42 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee @@ -95,6 +95,7 @@ module.exports = CollaboratorsHandler = for project in allProjects do (project) -> jobs.push (cb) -> + return cb() if !project? CollaboratorsHandler.removeUserFromProject project._id, user_id, cb async.series jobs, callback diff --git a/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee b/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee index 645c39076c..37e39aaacb 100644 --- a/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Collaborators/CollaboratorsHandlerTests.coffee @@ -276,13 +276,13 @@ describe "CollaboratorsHandler", -> it "should not add any users to the proejct", -> @CollaboratorHandler.addUserIdToProject.called.should.equal false - describe "removeUserFromAllProjets", -> + describe "removeUserFromAllProjects", -> beforeEach (done) -> @CollaboratorHandler.getProjectsUserIsCollaboratorOf = sinon.stub() @CollaboratorHandler.getProjectsUserIsCollaboratorOf.withArgs(@user_id, { _id: 1 }).yields( null, - [ { _id: "read-and-write-0" }, { _id: "read-and-write-1" } ], - [ { _id: "read-only-0" }, { _id: "read-only-1" } ] + [ { _id: "read-and-write-0" }, { _id: "read-and-write-1" }, null ], + [ { _id: "read-only-0" }, { _id: "read-only-1" }, null ] ) @CollaboratorHandler.removeUserFromProject = sinon.stub().yields() @CollaboratorHandler.removeUserFromAllProjets @user_id, done