From 4349e8544405252ca04f01d594481271d9cee84a Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Wed, 6 May 2020 09:58:29 -0500 Subject: [PATCH] Merge pull request #2813 from overleaf/ns-ta-group-account-admin Add admin to group account when new group account is created GitOrigin-RevId: 81c49a0b414896153a85a8ba1afc364164047c1c --- .../src/Features/Subscription/SubscriptionUpdater.js | 4 ++++ .../unit/src/Subscription/SubscriptionUpdaterTests.js | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) 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() } )