Rename getProjectsUserIsCollaboratorOf to ...IsMemberOf

This brings the naming more in line with current conventions.
This commit is contained in:
Shane Kilkelly 2017-09-20 13:16:50 +01:00
parent 069f49d5a6
commit ceb7c509d0
5 changed files with 10 additions and 9 deletions

View file

@ -107,7 +107,7 @@ module.exports = CollaboratorsHandler =
return callback null, true, member.privilegeLevel
return callback null, false, null
getProjectsUserIsCollaboratorOf: (user_id, fields, callback = (error, readAndWriteProjects, readOnlyProjects) ->) ->
getProjectsUserIsMemberOf: (user_id, fields, callback = (error, readAndWriteProjects, readOnlyProjects) ->) ->
Project.find {collaberator_refs:user_id}, fields, (err, readAndWriteProjects)=>
return callback(err) if err?
Project.find {readOnly_refs:user_id}, fields, (err, readOnlyProjects)=>
@ -125,7 +125,7 @@ module.exports = CollaboratorsHandler =
callback(err)
removeUserFromAllProjets: (user_id, callback = (error) ->) ->
CollaboratorsHandler.getProjectsUserIsCollaboratorOf user_id, { _id: 1 }, (error, readAndWriteProjects = [], readOnlyProjects = []) ->
CollaboratorsHandler.getProjectsUserIsMemberOf user_id, { _id: 1 }, (error, readAndWriteProjects = [], readOnlyProjects = []) ->
return callback(error) if error?
allProjects = readAndWriteProjects.concat(readOnlyProjects)
jobs = []

View file

@ -38,6 +38,7 @@ module.exports = ProjectDeleter =
archiveProject: (project_id, callback = (error) ->)->
logger.log project_id:project_id, "archived project from user request"
# TODO: the *_refs properties are probably not needed here
ProjectGetter.getProject project_id, {owner_ref:true, collaberator_refs:true, readOnly_refs:true}, (err, project)=>
if err? or !project?
logger.err err:err, project_id:project_id, "error getting project to archived it"

View file

@ -55,7 +55,7 @@ module.exports = ProjectGetter =
CollaboratorsHandler = require "../Collaborators/CollaboratorsHandler"
Project.find {owner_ref: user_id}, fields, (error, projects) ->
return callback(error) if error?
CollaboratorsHandler.getProjectsUserIsCollaboratorOf user_id, fields, (error, readAndWriteProjects, readOnlyProjects) ->
CollaboratorsHandler.getProjectsUserIsMemberOf user_id, fields, (error, readAndWriteProjects, readOnlyProjects) ->
return callback(error) if error?
callback null, projects, readAndWriteProjects, readOnlyProjects

View file

@ -186,13 +186,13 @@ describe "CollaboratorsHandler", ->
.calledWith(null, false, null)
.should.equal true
describe "getProjectsUserIsCollaboratorOf", ->
describe "getProjectsUserIsMemberOf", ->
beforeEach ->
@fields = "mock fields"
@Project.find = sinon.stub()
@Project.find.withArgs({collaberator_refs:@user_id}, @fields).yields(null, ["mock-read-write-project-1", "mock-read-write-project-2"])
@Project.find.withArgs({readOnly_refs:@user_id}, @fields).yields(null, ["mock-read-only-project-1", "mock-read-only-project-2"])
@CollaboratorHandler.getProjectsUserIsCollaboratorOf @user_id, @fields, @callback
@CollaboratorHandler.getProjectsUserIsMemberOf @user_id, @fields, @callback
it "should call the callback with the projects", ->
@callback
@ -279,8 +279,8 @@ describe "CollaboratorsHandler", ->
describe "removeUserFromAllProjects", ->
beforeEach (done) ->
@CollaboratorHandler.getProjectsUserIsCollaboratorOf = sinon.stub()
@CollaboratorHandler.getProjectsUserIsCollaboratorOf.withArgs(@user_id, { _id: 1 }).yields(
@CollaboratorHandler.getProjectsUserIsMemberOf = sinon.stub()
@CollaboratorHandler.getProjectsUserIsMemberOf.withArgs(@user_id, { _id: 1 }).yields(
null,
[ { _id: "read-and-write-0" }, { _id: "read-and-write-1" }, null ],
[ { _id: "read-only-0" }, { _id: "read-only-1" }, null ]

View file

@ -148,8 +148,8 @@ describe "ProjectGetter", ->
@fields = {"mock": "fields"}
@Project.find = sinon.stub()
@Project.find.withArgs({owner_ref: @user_id}, @fields).yields(null, ["mock-owned-projects"])
@CollaboratorsHandler.getProjectsUserIsCollaboratorOf = sinon.stub()
@CollaboratorsHandler.getProjectsUserIsCollaboratorOf.withArgs(@user_id, @fields).yields(null, ["mock-rw-projects"], ["mock-ro-projects"])
@CollaboratorsHandler.getProjectsUserIsMemberOf = sinon.stub()
@CollaboratorsHandler.getProjectsUserIsMemberOf.withArgs(@user_id, @fields).yields(null, ["mock-rw-projects"], ["mock-ro-projects"])
@ProjectGetter.findAllUsersProjects @user_id, @fields, @callback
it "should call the callback with all the projects", ->