Просмотр исходного кода

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.
Shane Kilkelly 9 лет назад
Родитель
Сommit
069f49d5a6

+ 4 - 4
services/web/app/coffee/Features/Collaborators/CollaboratorsHandler.coffee

@@ -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
 

+ 1 - 1
services/web/app/coffee/Features/Subscription/LimitationsManager.coffee

@@ -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?

+ 1 - 1
services/web/test/UnitTests/coffee/Subscription/LimitationsManagerTests.coffee

@@ -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",