diff --git a/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee b/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee index 63bd5e785c..889fdf17df 100644 --- a/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee +++ b/services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee @@ -215,7 +215,8 @@ module.exports = CollaboratorsHandler = else return callback(new Error("unknown privilegeLevel: #{privilegeLevel}")) - ContactManager.addContact adding_user_id, user_id + if adding_user_id + ContactManager.addContact adding_user_id, user_id Project.update { _id: project_id }, { $addToSet: level }, (error) -> return callback(error) if error? diff --git a/services/web/test/unit/coffee/Collaborators/CollaboratorsHandlerTests.coffee b/services/web/test/unit/coffee/Collaborators/CollaboratorsHandlerTests.coffee index cb1b5f3dc3..4a2c33a2aa 100644 --- a/services/web/test/unit/coffee/Collaborators/CollaboratorsHandlerTests.coffee +++ b/services/web/test/unit/coffee/Collaborators/CollaboratorsHandlerTests.coffee @@ -322,6 +322,13 @@ describe "CollaboratorsHandler", -> it "should not add the user again", -> @Project.update.called.should.equal false + describe "with null adding_user_id", -> + beforeEach -> + @CollaboratorHandler.addUserIdToProject @project_id, null, @user_id, "readAndWrite", @callback + + it "should not add the adding user as a contact", -> + @ContactManager.addContact.called.should.equal(false) + describe "removeUserFromAllProjects", -> beforeEach (done) -> @CollaboratorHandler.getProjectsUserIsMemberOf = sinon.stub()