mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 12:39:33 -05:00
3d94be22b1
Manage Group Members GitOrigin-RevId: f0b120630ded1874dfc0352055633afff0015da9
55 lines
1.6 KiB
CoffeeScript
55 lines
1.6 KiB
CoffeeScript
SandboxedModule = require('sandboxed-module')
|
|
should = require('chai').should()
|
|
sinon = require 'sinon'
|
|
assert = require("chai").assert
|
|
modulePath = "../../../../app/js/Features/Subscription/SubscriptionGroupController"
|
|
MockResponse = require "../helpers/MockResponse"
|
|
|
|
describe "SubscriptionGroupController", ->
|
|
|
|
beforeEach ->
|
|
@user = {_id:"!@312431",email:"user@email.com"}
|
|
@adminUserId = "123jlkj"
|
|
@subscriptionId = "123434325412"
|
|
@user_email = "bob@gmail.com"
|
|
@req =
|
|
session:
|
|
user:
|
|
_id: @adminUserId
|
|
email:@user_email
|
|
params:
|
|
subscriptionId:@subscriptionId
|
|
query:{}
|
|
|
|
@subscription = {
|
|
_id: @subscriptionId
|
|
}
|
|
|
|
@GroupHandler =
|
|
removeUserFromGroup: sinon.stub().callsArgWith(2)
|
|
|
|
@SubscriptionLocator =
|
|
findManagedSubscription: sinon.stub().callsArgWith(1, null, @subscription)
|
|
|
|
@AuthenticationController =
|
|
getLoggedInUserId: (req) -> req.session.user._id
|
|
getSessionUser: (req) -> req.session.user
|
|
|
|
@Controller = SandboxedModule.require modulePath, requires:
|
|
"./SubscriptionGroupHandler":@GroupHandler
|
|
"logger-sharelatex": log:->
|
|
"./SubscriptionLocator": @SubscriptionLocator
|
|
'../Authentication/AuthenticationController': @AuthenticationController
|
|
|
|
|
|
describe "removeUserFromGroup", ->
|
|
it "should use the subscription id for the logged in user and take the user id from the params", (done)->
|
|
userIdToRemove = "31231"
|
|
@req.params = user_id: userIdToRemove
|
|
@req.entity = @subscription
|
|
|
|
res =
|
|
send : =>
|
|
@GroupHandler.removeUserFromGroup.calledWith(@subscriptionId, userIdToRemove).should.equal true
|
|
done()
|
|
@Controller.removeUserFromGroup @req, res
|