Merge pull request #3064 from overleaf/ta-manage-multiple-groups

Allow Users to Manage Multiple Groups

GitOrigin-RevId: c918da0114cdd1d679223f69d81159b4c2608874
This commit is contained in:
Timothée Alby
2020-08-13 02:06:20 +00:00
committed by Copybot
parent 29f09c50c2
commit 8cd6e7ccfc
9 changed files with 41 additions and 89 deletions
@@ -44,9 +44,7 @@ describe('SubscriptionGroupController', function() {
this.GroupHandler = { removeUserFromGroup: sinon.stub().callsArgWith(2) }
this.SubscriptionLocator = {
findManagedSubscription: sinon
.stub()
.callsArgWith(1, null, this.subscription)
getSubscription: sinon.stub().callsArgWith(1, null, this.subscription)
}
this.AuthenticationController = {
@@ -91,4 +89,29 @@ describe('SubscriptionGroupController', function() {
return this.Controller.removeUserFromGroup(this.req, res)
})
})
describe('removeSelfFromGroup', function() {
it('gets subscription and remove user', function(done) {
const userIdToRemove = '31231'
this.req.query = { subscriptionId: this.subscriptionId }
const memberUserIdToremove = 123456789
this.req.session.user._id = memberUserIdToremove
const res = {
sendStatus: () => {
sinon.assert.calledWith(
this.SubscriptionLocator.getSubscription,
this.subscriptionId
)
sinon.assert.calledWith(
this.GroupHandler.removeUserFromGroup,
this.subscriptionId,
memberUserIdToremove
)
return done()
}
}
return this.Controller.removeSelfFromGroup(this.req, res)
})
})
})
@@ -88,21 +88,5 @@ describe('Subscription Locator Tests', function() {
}
)
})
describe('finding managed subscription', function() {
it('should query the database', function(done) {
this.Subscription.findOne.callsArgWith(1, null, this.subscription)
return this.SubscriptionLocator.findManagedSubscription(
this.user._id,
(err, subscription) => {
this.Subscription.findOne
.calledWith({ manager_ids: this.user._id })
.should.equal(true)
subscription.should.equal(this.subscription)
return done()
}
)
})
})
})
})