From abcfa0b0d2b4b8ee2ec56d363ff99d8137cf8a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Fern=C3=A1ndez=20Capel?= Date: Fri, 29 Jun 2018 11:22:58 +0100 Subject: [PATCH] Store manager ids in an array --- .../coffee/Features/Subscription/SubscriptionUpdater.coffee | 2 +- services/web/app/coffee/models/Subscription.coffee | 1 + .../unit/coffee/Subscription/SubscriptionUpdaterTests.coffee | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) 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()