mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Store manager ids in an array
This commit is contained in:
parent
71351476f7
commit
abcfa0b0d2
3 changed files with 6 additions and 1 deletions
|
@ -71,7 +71,7 @@ module.exports = SubscriptionUpdater =
|
||||||
|
|
||||||
_createNewSubscription: (adminUser_id, callback)->
|
_createNewSubscription: (adminUser_id, callback)->
|
||||||
logger.log adminUser_id:adminUser_id, "creating new subscription"
|
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.freeTrial.allowed = false
|
||||||
subscription.save (err)->
|
subscription.save (err)->
|
||||||
callback err, subscription
|
callback err, subscription
|
||||||
|
|
|
@ -7,6 +7,7 @@ ObjectId = Schema.ObjectId
|
||||||
|
|
||||||
SubscriptionSchema = new Schema
|
SubscriptionSchema = new Schema
|
||||||
admin_id : {type:ObjectId, ref:'User', index: {unique: true, dropDups: true}}
|
admin_id : {type:ObjectId, ref:'User', index: {unique: true, dropDups: true}}
|
||||||
|
manager_ids : [ type:ObjectId, ref:'User' ]
|
||||||
member_ids : [ type:ObjectId, ref:'User' ]
|
member_ids : [ type:ObjectId, ref:'User' ]
|
||||||
invited_emails: [ String ]
|
invited_emails: [ String ]
|
||||||
teamInvites : [ TeamInviteSchema ]
|
teamInvites : [ TeamInviteSchema ]
|
||||||
|
|
|
@ -20,6 +20,7 @@ describe "SubscriptionUpdater", ->
|
||||||
@subscription = subscription =
|
@subscription = subscription =
|
||||||
_id: "111111111111111111111111"
|
_id: "111111111111111111111111"
|
||||||
admin_id: @adminUser._id
|
admin_id: @adminUser._id
|
||||||
|
manager_ids: [@adminUser._id]
|
||||||
member_ids: @allUserIds
|
member_ids: @allUserIds
|
||||||
save: sinon.stub().callsArgWith(0)
|
save: sinon.stub().callsArgWith(0)
|
||||||
freeTrial:{}
|
freeTrial:{}
|
||||||
|
@ -29,6 +30,7 @@ describe "SubscriptionUpdater", ->
|
||||||
@groupSubscription =
|
@groupSubscription =
|
||||||
_id: "222222222222222222222222"
|
_id: "222222222222222222222222"
|
||||||
admin_id: @adminUser._id
|
admin_id: @adminUser._id
|
||||||
|
manager_ids: [@adminUser._id]
|
||||||
member_ids: @allUserIds
|
member_ids: @allUserIds
|
||||||
save: sinon.stub().callsArgWith(0)
|
save: sinon.stub().callsArgWith(0)
|
||||||
freeTrial:{}
|
freeTrial:{}
|
||||||
|
@ -40,6 +42,7 @@ describe "SubscriptionUpdater", ->
|
||||||
@SubscriptionModel = class
|
@SubscriptionModel = class
|
||||||
constructor: (opts)->
|
constructor: (opts)->
|
||||||
subscription.admin_id = opts.admin_id
|
subscription.admin_id = opts.admin_id
|
||||||
|
subscription.manager_ids = [opts.admin_id]
|
||||||
return subscription
|
return subscription
|
||||||
@remove: sinon.stub().yields()
|
@remove: sinon.stub().yields()
|
||||||
@SubscriptionModel.update = @updateStub
|
@SubscriptionModel.update = @updateStub
|
||||||
|
@ -151,6 +154,7 @@ describe "SubscriptionUpdater", ->
|
||||||
it "should create a new subscription then update the subscription", (done)->
|
it "should create a new subscription then update the subscription", (done)->
|
||||||
@SubscriptionUpdater._createNewSubscription @adminUser._id, =>
|
@SubscriptionUpdater._createNewSubscription @adminUser._id, =>
|
||||||
@subscription.admin_id.should.equal @adminUser._id
|
@subscription.admin_id.should.equal @adminUser._id
|
||||||
|
@subscription.manager_ids.should.deep.equal [@adminUser._id]
|
||||||
@subscription.freeTrial.allowed.should.equal false
|
@subscription.freeTrial.allowed.should.equal false
|
||||||
@subscription.save.called.should.equal true
|
@subscription.save.called.should.equal true
|
||||||
done()
|
done()
|
||||||
|
|
Loading…
Reference in a new issue