Change getCollaboratorCount to getInvitedCollaboratorCount.

And update the one call-site in LimitationsManager. This function
is used to limit invites, so it makes sense to explicitely limit
this to Invited members of the project.
This commit is contained in:
Shane Kilkelly 2017-09-20 10:29:47 +01:00
parent 8460160076
commit 069f49d5a6
3 changed files with 6 additions and 6 deletions

View file

@ -89,13 +89,13 @@ module.exports = CollaboratorsHandler =
return callback null, member.privilegeLevel
return callback null, PrivilegeLevels.NONE
getMemberCount: (project_id, callback = (error, count) ->) ->
getInvitedMemberCount: (project_id, callback = (error, count) ->) ->
CollaboratorsHandler.getMemberIdsWithPrivilegeLevels project_id, (error, members) ->
return callback(error) if error?
return callback null, (members or []).length
return callback null, (members or []).filter((m) -> m.source == Sources.INVITE).length
getCollaboratorCount: (project_id, callback = (error, count) ->) ->
CollaboratorsHandler.getMemberCount project_id, (error, count) ->
getInvitedCollaboratorCount: (project_id, callback = (error, count) ->) ->
CollaboratorsHandler.getInvitedMemberCount project_id, (error, count) ->
return callback(error) if error?
return callback null, count - 1 # Don't count project owner

View file

@ -24,7 +24,7 @@ module.exports =
canAddXCollaborators: (project_id, x_collaborators, callback = (error, allowed)->) ->
@allowedNumberOfCollaboratorsInProject project_id, (error, allowed_number) =>
return callback(error) if error?
CollaboratorsHandler.getCollaboratorCount project_id, (error, current_number) =>
CollaboratorsHandler.getInvitedCollaboratorCount project_id, (error, current_number) =>
return callback(error) if error?
CollaboratorsInvitesHandler.getInviteCount project_id, (error, invite_count) =>
return callback(error) if error?

View file

@ -79,7 +79,7 @@ describe "LimitationsManager", ->
describe "canAddXCollaborators", ->
beforeEach ->
@CollaboratorsHandler.getCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager,
"allowedNumberOfCollaboratorsInProject",