mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-06 15:49:01 +02:00
Move admin register to user activate module
Move admin register to user activate module Co-authored-by: John Lees-Miller <jdleesmiller@gmail.com> & Davinder Singh GitOrigin-RevId: 79428f2932783086435bdad9b1efb5300c467511
This commit is contained in:
@@ -17,21 +17,27 @@ describe('UserActivateController', function () {
|
||||
}
|
||||
|
||||
this.UserGetter = { getUser: sinon.stub() }
|
||||
this.UserRegistrationHandler = {}
|
||||
this.ErrorController = { notFound: sinon.stub() }
|
||||
this.UserActivateController = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
'../../../../app/src/Features/User/UserGetter': this.UserGetter,
|
||||
'../../../../app/src/Features/User/UserRegistrationHandler':
|
||||
this.UserRegistrationHandler,
|
||||
'../../../../app/src/Features/Errors/ErrorController':
|
||||
this.ErrorController,
|
||||
},
|
||||
})
|
||||
this.req = {
|
||||
body: {},
|
||||
query: {},
|
||||
session: {
|
||||
user: this.user,
|
||||
},
|
||||
}
|
||||
this.res = {}
|
||||
this.res = {
|
||||
json: sinon.stub(),
|
||||
}
|
||||
})
|
||||
|
||||
describe('activateAccountPage', function () {
|
||||
@@ -86,4 +92,30 @@ describe('UserActivateController', function () {
|
||||
this.UserActivateController.activateAccountPage(this.req, this.res)
|
||||
})
|
||||
})
|
||||
|
||||
describe('register', function () {
|
||||
beforeEach(function () {
|
||||
this.UserRegistrationHandler.registerNewUserAndSendActivationEmail = sinon
|
||||
.stub()
|
||||
.callsArgWith(1, null, this.user, (this.url = 'mock/url'))
|
||||
this.req.body.email = this.user.email = this.email = 'email@example.com'
|
||||
this.UserActivateController.register(this.req, this.res)
|
||||
})
|
||||
|
||||
it('should register the user and send them an email', function () {
|
||||
sinon.assert.calledWith(
|
||||
this.UserRegistrationHandler.registerNewUserAndSendActivationEmail,
|
||||
this.email
|
||||
)
|
||||
})
|
||||
|
||||
it('should return the user and activation url', function () {
|
||||
this.res.json
|
||||
.calledWith({
|
||||
email: this.email,
|
||||
setNewPasswordUrl: this.url,
|
||||
})
|
||||
.should.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user