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

Check the subscription is in a group plan before adding new members

Alberto Fernández Capel 8 лет назад
Родитель
Сommit
5159f6f33d

+ 5 - 0
services/web/app/coffee/Features/Subscription/TeamInvitesHandler.coffee

@@ -124,6 +124,11 @@ removeInviteFromTeam = (subscriptionId, email, callback) ->
 
 
 checkIfInviteIsPossible = (subscription, email, callback = (error, possible, reason) -> ) ->
+	unless subscription.groupPlan
+		logger.log {subscriptionId: subscription.id},
+			"can not add members to a subscription that is not in a group plan"
+		return callback(null, false, wrongPlan: true)
+
 	if LimitationsManager.teamHasReachedMemberLimit(subscription)
 		logger.log {subscriptionId: subscription.id}, "team has reached member limit"
 		return callback(null, false, limitReached: true)

+ 10 - 3
services/web/test/unit/coffee/Subscription/TeamInvitesHandlerTests.coffee

@@ -26,9 +26,10 @@ describe "TeamInvitesHandler", ->
 		@subscription = {
 			id: "55153a8014829a865bbf700d",
 			admin_id: @manager.id,
-			member_ids: []
-			teamInvites: [ @teamInvite ]
-			save: sinon.stub().yields(null)
+			groupPlan: true,
+			member_ids: [],
+			teamInvites: [ @teamInvite ],
+			save: sinon.stub().yields(null),
 		}
 
 		@SubscriptionLocator = {
@@ -234,6 +235,12 @@ describe "TeamInvitesHandler", ->
 				expect(err).to.deep.equal(limitReached: true)
 				done()
 
+		it "doesn't create an invite if the subscription is not in a group plan", (done) ->
+			@subscription.groupPlan = false
+			@TeamInvitesHandler.createInvite @manager.id, "John.Snow@nightwatch.com", (err, invite) =>
+				expect(err).to.deep.equal(wrongPlan: true)
+				done()
+
 		it "doesn't create an invite if the user is already part of the team", (done) ->
 			member = {
 				id: "1a2b",