diff --git a/services/web/app/src/Features/Subscription/SubscriptionUpdater.js b/services/web/app/src/Features/Subscription/SubscriptionUpdater.js index 4d5bb96976..be0d490d61 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionUpdater.js +++ b/services/web/app/src/Features/Subscription/SubscriptionUpdater.js @@ -265,6 +265,10 @@ const SubscriptionUpdater = { ) } if (plan.groupPlan) { + if (!subscription.groupPlan) { + subscription.member_ids = subscription.member_ids || [] + subscription.member_ids.push(subscription.admin_id) + } subscription.groupPlan = true subscription.membersLimit = plan.membersLimit } diff --git a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js index 939550a8ce..6da6a30c59 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionUpdaterTests.js @@ -23,7 +23,7 @@ describe('SubscriptionUpdater', function() { _id: '111111111111111111111111', admin_id: this.adminUser._id, manager_ids: [this.adminUser._id], - member_ids: this.allUserIds, + member_ids: [], save: sinon.stub().callsArgWith(0), planCode: 'student_or_something' } @@ -241,6 +241,10 @@ describe('SubscriptionUpdater', function() { this.SubscriptionUpdater.deleteSubscription = sinon.stub().yields() }) + afterEach(function() { + this.subscription.member_ids = [] + }) + it('should update the subscription with token etc when not expired', function(done) { this.SubscriptionUpdater._updateSubscriptionFromRecurly( this.recurlySubscription, @@ -284,6 +288,7 @@ describe('SubscriptionUpdater', function() { }) it('should update all the users features', function(done) { + this.subscription.member_ids = this.allUserIds this.SubscriptionUpdater._updateSubscriptionFromRecurly( this.recurlySubscription, this.subscription, @@ -323,6 +328,9 @@ describe('SubscriptionUpdater', function() { } this.subscription.membersLimit.should.equal(5) this.subscription.groupPlan.should.equal(true) + this.subscription.member_ids.should.deep.equal([ + this.subscription.admin_id + ]) done() } )