diff --git a/services/web/app/coffee/Features/Subscription/TeamInvitesHandler.coffee b/services/web/app/coffee/Features/Subscription/TeamInvitesHandler.coffee index 885e729394..b84cda82f0 100644 --- a/services/web/app/coffee/Features/Subscription/TeamInvitesHandler.coffee +++ b/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) diff --git a/services/web/test/unit/coffee/Subscription/TeamInvitesHandlerTests.coffee b/services/web/test/unit/coffee/Subscription/TeamInvitesHandlerTests.coffee index 81a1d2718f..720c8fadf7 100644 --- a/services/web/test/unit/coffee/Subscription/TeamInvitesHandlerTests.coffee +++ b/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",