diff --git a/services/web/app/src/models/Subscription.js b/services/web/app/src/models/Subscription.js index 8d477c6945..0e5d9c9f82 100644 --- a/services/web/app/src/models/Subscription.js +++ b/services/web/app/src/models/Subscription.js @@ -23,7 +23,7 @@ const SubscriptionSchema = new Schema({ ref: 'User', index: { unique: true, dropDups: true } }, - manager_ids: [{ type: ObjectId, ref: 'User' }], + manager_ids: { type: [ObjectId], ref: 'User', required: true }, member_ids: [{ type: ObjectId, ref: 'User' }], invited_emails: [String], teamInvites: [TeamInviteSchema], diff --git a/services/web/test/acceptance/src/FeatureUpdaterTests.js b/services/web/test/acceptance/src/FeatureUpdaterTests.js index 5c375c1223..1357a94557 100644 --- a/services/web/test/acceptance/src/FeatureUpdaterTests.js +++ b/services/web/test/acceptance/src/FeatureUpdaterTests.js @@ -94,8 +94,10 @@ describe('FeatureUpdater.refreshFeatures', function() { describe('when the user is in a group subscription', function() { beforeEach(function() { + const groupAdminId = ObjectId() return Subscription.create({ - admin_id: ObjectId(), + admin_id: groupAdminId, + manager_ids: [groupAdminId], member_ids: [this.user._id], groupAccount: true, planCode: 'collaborator', @@ -280,6 +282,8 @@ describe('FeatureUpdater.refreshFeatures', function() { describe('when the user has a group and personal subscription', function() { beforeEach(function(done) { + const groupAdminId = ObjectId() + Subscription.create( { admin_id: this.user._id, @@ -293,7 +297,8 @@ describe('FeatureUpdater.refreshFeatures', function() { } return Subscription.create( { - admin_id: ObjectId(), + admin_id: groupAdminId, + manager_ids: [groupAdminId], member_ids: [this.user._id], groupAccount: true, planCode: 'collaborator', diff --git a/services/web/test/acceptance/src/helpers/Subscription.js b/services/web/test/acceptance/src/helpers/Subscription.js index d415abe55b..57d57aedc2 100644 --- a/services/web/test/acceptance/src/helpers/Subscription.js +++ b/services/web/test/acceptance/src/helpers/Subscription.js @@ -11,7 +11,7 @@ class Subscription { this.admin_id = options.adminId || ObjectId() this.overleaf = options.overleaf || {} this.groupPlan = options.groupPlan - this.manager_ids = [] + this.manager_ids = options.managerIds || [this.admin_id] this.member_ids = options.memberIds || [] this.invited_emails = options.invitedEmails || [] this.teamInvites = options.teamInvites || [] @@ -28,8 +28,11 @@ class Subscription { this, options, (error, subscription) => { + if (error) { + return callback(error) + } this._id = subscription._id - callback(error) + callback() } ) }