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-12 16:17:15 +02: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)
})
})
})