Merge pull request #715 from sharelatex/afc-multiple-managers

Store team managers in an array
This commit is contained in:
Alberto Fernández-Capel 2018-07-16 09:59:29 +01:00 committed by GitHub
commit 2d43de20bf
3 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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 ]

View file

@ -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()