diff --git a/services/web/app/coffee/Features/Subscription/SubscriptionUpdater.coffee b/services/web/app/coffee/Features/Subscription/SubscriptionUpdater.coffee index aea2042b06..edcc58d57e 100644 --- a/services/web/app/coffee/Features/Subscription/SubscriptionUpdater.coffee +++ b/services/web/app/coffee/Features/Subscription/SubscriptionUpdater.coffee @@ -71,7 +71,7 @@ module.exports = SubscriptionUpdater = _createNewSubscription: (adminUser_id, callback)-> logger.log adminUser_id:adminUser_id, "creating new subscription" - subscription = new Subscription(admin_id:adminUser_id) + subscription = new Subscription(admin_id:adminUser_id, manager_ids: [adminUser_id]) subscription.freeTrial.allowed = false subscription.save (err)-> callback err, subscription diff --git a/services/web/app/coffee/models/Subscription.coffee b/services/web/app/coffee/models/Subscription.coffee index f739c14e2c..0e892a2ad6 100644 --- a/services/web/app/coffee/models/Subscription.coffee +++ b/services/web/app/coffee/models/Subscription.coffee @@ -7,6 +7,7 @@ ObjectId = Schema.ObjectId SubscriptionSchema = new Schema admin_id : {type:ObjectId, ref:'User', index: {unique: true, dropDups: true}} + manager_ids : [ type:ObjectId, ref:'User' ] member_ids : [ type:ObjectId, ref:'User' ] invited_emails: [ String ] teamInvites : [ TeamInviteSchema ] diff --git a/services/web/test/unit/coffee/Subscription/SubscriptionUpdaterTests.coffee b/services/web/test/unit/coffee/Subscription/SubscriptionUpdaterTests.coffee index f88dac383f..a66d7f5dec 100644 --- a/services/web/test/unit/coffee/Subscription/SubscriptionUpdaterTests.coffee +++ b/services/web/test/unit/coffee/Subscription/SubscriptionUpdaterTests.coffee @@ -20,6 +20,7 @@ describe "SubscriptionUpdater", -> @subscription = subscription = _id: "111111111111111111111111" admin_id: @adminUser._id + manager_ids: [@adminUser._id] member_ids: @allUserIds save: sinon.stub().callsArgWith(0) freeTrial:{} @@ -29,6 +30,7 @@ describe "SubscriptionUpdater", -> @groupSubscription = _id: "222222222222222222222222" admin_id: @adminUser._id + manager_ids: [@adminUser._id] member_ids: @allUserIds save: sinon.stub().callsArgWith(0) freeTrial:{} @@ -40,6 +42,7 @@ describe "SubscriptionUpdater", -> @SubscriptionModel = class constructor: (opts)-> subscription.admin_id = opts.admin_id + subscription.manager_ids = [opts.admin_id] return subscription @remove: sinon.stub().yields() @SubscriptionModel.update = @updateStub @@ -151,6 +154,7 @@ describe "SubscriptionUpdater", -> it "should create a new subscription then update the subscription", (done)-> @SubscriptionUpdater._createNewSubscription @adminUser._id, => @subscription.admin_id.should.equal @adminUser._id + @subscription.manager_ids.should.deep.equal [@adminUser._id] @subscription.freeTrial.allowed.should.equal false @subscription.save.called.should.equal true done()