mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
@@ -19,8 +19,8 @@ const modulePath = require('path').join(
|
||||
'../../../app/src/LaunchpadController.js'
|
||||
)
|
||||
|
||||
describe('LaunchpadController', function() {
|
||||
beforeEach(function() {
|
||||
describe('LaunchpadController', function () {
|
||||
beforeEach(function () {
|
||||
this.user = {
|
||||
_id: '323123',
|
||||
first_name: 'fn',
|
||||
@@ -59,8 +59,8 @@ describe('LaunchpadController', function() {
|
||||
return (this.next = sinon.stub())
|
||||
})
|
||||
|
||||
describe('launchpadPage', function() {
|
||||
beforeEach(function() {
|
||||
describe('launchpadPage', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists = sinon.stub(
|
||||
this.LaunchpadController,
|
||||
'_atLeastOneAdminExists'
|
||||
@@ -68,20 +68,20 @@ describe('LaunchpadController', function() {
|
||||
return (this.AuthenticationController.setRedirectInSession = sinon.stub())
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
return this._atLeastOneAdminExists.restore()
|
||||
})
|
||||
|
||||
describe('when the user is not logged in', function() {
|
||||
beforeEach(function() {
|
||||
describe('when the user is not logged in', function () {
|
||||
beforeEach(function () {
|
||||
this.AuthenticationController.getSessionUser = sinon
|
||||
.stub()
|
||||
.returns(null)
|
||||
return (this.res.render = sinon.stub())
|
||||
})
|
||||
|
||||
describe('when there are no admins', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there are no admins', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
return this.LaunchpadController.launchpadPage(
|
||||
this.req,
|
||||
@@ -90,7 +90,7 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should render the launchpad page', function() {
|
||||
it('should render the launchpad page', function () {
|
||||
const viewPath = require('path').join(
|
||||
__dirname,
|
||||
'../../../app/views/launchpad'
|
||||
@@ -105,8 +105,8 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when there is at least one admin', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there is at least one admin', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, true)
|
||||
return this.LaunchpadController.launchpadPage(
|
||||
this.req,
|
||||
@@ -115,21 +115,21 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should redirect to login page', function() {
|
||||
it('should redirect to login page', function () {
|
||||
this.AuthenticationController.setRedirectInSession.callCount.should.equal(
|
||||
1
|
||||
)
|
||||
this.res.redirect.calledWith('/login').should.equal(true)
|
||||
})
|
||||
|
||||
it('should not render the launchpad page', function() {
|
||||
it('should not render the launchpad page', function () {
|
||||
return this.res.render.callCount.should.equal(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the user is logged in', function() {
|
||||
beforeEach(function() {
|
||||
describe('when the user is logged in', function () {
|
||||
beforeEach(function () {
|
||||
this.user = {
|
||||
_id: 'abcd',
|
||||
email: 'abcd@example.com'
|
||||
@@ -142,8 +142,8 @@ describe('LaunchpadController', function() {
|
||||
return (this.res.redirect = sinon.stub())
|
||||
})
|
||||
|
||||
describe('when the user is an admin', function() {
|
||||
beforeEach(function() {
|
||||
describe('when the user is an admin', function () {
|
||||
beforeEach(function () {
|
||||
this.UserGetter.getUser = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, { isAdmin: true })
|
||||
@@ -154,7 +154,7 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should render the launchpad page', function() {
|
||||
it('should render the launchpad page', function () {
|
||||
const viewPath = require('path').join(
|
||||
__dirname,
|
||||
'../../../app/views/launchpad'
|
||||
@@ -170,8 +170,8 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the user is not an admin', function() {
|
||||
beforeEach(function() {
|
||||
describe('when the user is not an admin', function () {
|
||||
beforeEach(function () {
|
||||
this.UserGetter.getUser = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, { isAdmin: false })
|
||||
@@ -182,7 +182,7 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should redirect to restricted page', function() {
|
||||
it('should redirect to restricted page', function () {
|
||||
this.res.redirect.callCount.should.equal(1)
|
||||
return this.res.redirect.calledWith('/restricted').should.equal(true)
|
||||
})
|
||||
@@ -190,15 +190,15 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('_atLeastOneAdminExists', function() {
|
||||
describe('when there are no admins', function() {
|
||||
beforeEach(function() {
|
||||
describe('_atLeastOneAdminExists', function () {
|
||||
describe('when there are no admins', function () {
|
||||
beforeEach(function () {
|
||||
return (this.UserGetter.getUser = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, null))
|
||||
})
|
||||
|
||||
it('should callback with false', function(done) {
|
||||
it('should callback with false', function (done) {
|
||||
return this.LaunchpadController._atLeastOneAdminExists(
|
||||
(err, exists) => {
|
||||
expect(err).to.equal(null)
|
||||
@@ -209,14 +209,14 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when there are some admins', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there are some admins', function () {
|
||||
beforeEach(function () {
|
||||
return (this.UserGetter.getUser = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, { _id: 'abcd' }))
|
||||
})
|
||||
|
||||
it('should callback with true', function(done) {
|
||||
it('should callback with true', function (done) {
|
||||
return this.LaunchpadController._atLeastOneAdminExists(
|
||||
(err, exists) => {
|
||||
expect(err).to.equal(null)
|
||||
@@ -227,14 +227,14 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when getUser produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when getUser produces an error', function () {
|
||||
beforeEach(function () {
|
||||
return (this.UserGetter.getUser = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, new Error('woops')))
|
||||
})
|
||||
|
||||
it('should produce an error', function(done) {
|
||||
it('should produce an error', function (done) {
|
||||
return this.LaunchpadController._atLeastOneAdminExists(
|
||||
(err, exists) => {
|
||||
expect(err).to.not.equal(null)
|
||||
@@ -247,26 +247,26 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('sendTestEmail', function() {
|
||||
beforeEach(function() {
|
||||
describe('sendTestEmail', function () {
|
||||
beforeEach(function () {
|
||||
this.EmailHandler.sendEmail = sinon.stub().callsArgWith(2, null)
|
||||
this.req.body.email = 'someone@example.com'
|
||||
this.res.sendStatus = sinon.stub()
|
||||
return (this.next = sinon.stub())
|
||||
})
|
||||
|
||||
it('should produce a 201 response', function() {
|
||||
it('should produce a 201 response', function () {
|
||||
this.LaunchpadController.sendTestEmail(this.req, this.res, this.next)
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(201).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not call next with an error', function() {
|
||||
it('should not call next with an error', function () {
|
||||
this.LaunchpadController.sendTestEmail(this.req, this.res, this.next)
|
||||
return this.next.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should have called sendEmail', function() {
|
||||
it('should have called sendEmail', function () {
|
||||
this.LaunchpadController.sendTestEmail(this.req, this.res, this.next)
|
||||
this.EmailHandler.sendEmail.callCount.should.equal(1)
|
||||
return this.EmailHandler.sendEmail
|
||||
@@ -274,26 +274,26 @@ describe('LaunchpadController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
describe('when sendEmail produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when sendEmail produces an error', function () {
|
||||
beforeEach(function () {
|
||||
return (this.EmailHandler.sendEmail = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, new Error('woops')))
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.LaunchpadController.sendTestEmail(this.req, this.res, this.next)
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when no email address is supplied', function() {
|
||||
beforeEach(function() {
|
||||
describe('when no email address is supplied', function () {
|
||||
beforeEach(function () {
|
||||
return (this.req.body.email = undefined)
|
||||
})
|
||||
|
||||
it('should produce a 400 response', function() {
|
||||
it('should produce a 400 response', function () {
|
||||
this.LaunchpadController.sendTestEmail(this.req, this.res, this.next)
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(400).should.equal(true)
|
||||
@@ -301,20 +301,20 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('registerAdmin', function() {
|
||||
beforeEach(function() {
|
||||
describe('registerAdmin', function () {
|
||||
beforeEach(function () {
|
||||
return (this._atLeastOneAdminExists = sinon.stub(
|
||||
this.LaunchpadController,
|
||||
'_atLeastOneAdminExists'
|
||||
))
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
return this._atLeastOneAdminExists.restore()
|
||||
})
|
||||
|
||||
describe('when all goes well', function() {
|
||||
beforeEach(function() {
|
||||
describe('when all goes well', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.password = 'a_really_bad_password'
|
||||
@@ -338,23 +338,23 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send back a json response', function() {
|
||||
it('should send back a json response', function () {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
return expect(this.res.json.lastCall.args[0].email).to.equal(this.email)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({ email: this.email, password: this.password })
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should have updated the user to make them an admin', function() {
|
||||
it('should have updated the user to make them an admin', function () {
|
||||
this.User.updateOne.callCount.should.equal(1)
|
||||
return this.User.updateOne
|
||||
.calledWithMatch(
|
||||
@@ -369,7 +369,7 @@ describe('LaunchpadController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should have set a redirect in session', function() {
|
||||
it('should have set a redirect in session', function () {
|
||||
this.AuthenticationController.setRedirectInSession.callCount.should.equal(
|
||||
1
|
||||
)
|
||||
@@ -379,8 +379,8 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when no email is supplied', function() {
|
||||
beforeEach(function() {
|
||||
describe('when no email is supplied', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = undefined
|
||||
this.password = 'a_really_bad_password'
|
||||
@@ -402,24 +402,24 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send a 400 response', function() {
|
||||
it('should send a 400 response', function () {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(400).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not check for existing admins', function() {
|
||||
it('should not check for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when no password is supplied', function() {
|
||||
beforeEach(function() {
|
||||
describe('when no password is supplied', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.password = undefined
|
||||
@@ -441,24 +441,24 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send a 400 response', function() {
|
||||
it('should send a 400 response', function () {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(400).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not check for existing admins', function() {
|
||||
it('should not check for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when there are already existing admins', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there are already existing admins', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, true)
|
||||
this.email = 'someone@example.com'
|
||||
this.password = 'a_really_bad_password'
|
||||
@@ -480,20 +480,20 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send a 403 response', function() {
|
||||
it('should send a 403 response', function () {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(403).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when checking admins produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when checking admins produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, new Error('woops'))
|
||||
this.email = 'someone@example.com'
|
||||
this.password = 'a_really_bad_password'
|
||||
@@ -515,24 +515,24 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when registerNewUser produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when registerNewUser produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.password = 'a_really_bad_password'
|
||||
@@ -556,29 +556,29 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({ email: this.email, password: this.password })
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should not call update', function() {
|
||||
it('should not call update', function () {
|
||||
return this.User.updateOne.callCount.should.equal(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when user update produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when user update produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.password = 'a_really_bad_password'
|
||||
@@ -602,16 +602,16 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({ email: this.email, password: this.password })
|
||||
@@ -619,8 +619,8 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when overleaf', function() {
|
||||
beforeEach(function() {
|
||||
describe('when overleaf', function () {
|
||||
beforeEach(function () {
|
||||
this.Settings.overleaf = { one: 1 }
|
||||
this.Settings.createV1AccountOnLogin = true
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
@@ -649,23 +649,23 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send back a json response', function() {
|
||||
it('should send back a json response', function () {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
return expect(this.res.json.lastCall.args[0].email).to.equal(this.email)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({ email: this.email, password: this.password })
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should have updated the user to make them an admin', function() {
|
||||
it('should have updated the user to make them an admin', function () {
|
||||
return this.User.updateOne
|
||||
.calledWith(
|
||||
{ _id: this.user._id },
|
||||
@@ -679,7 +679,7 @@ describe('LaunchpadController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should have set a redirect in session', function() {
|
||||
it('should have set a redirect in session', function () {
|
||||
this.AuthenticationController.setRedirectInSession.callCount.should.equal(
|
||||
1
|
||||
)
|
||||
@@ -690,8 +690,8 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('registerExternalAuthAdmin', function() {
|
||||
beforeEach(function() {
|
||||
describe('registerExternalAuthAdmin', function () {
|
||||
beforeEach(function () {
|
||||
this.Settings.ldap = { one: 1 }
|
||||
return (this._atLeastOneAdminExists = sinon.stub(
|
||||
this.LaunchpadController,
|
||||
@@ -699,12 +699,12 @@ describe('LaunchpadController', function() {
|
||||
))
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
return this._atLeastOneAdminExists.restore()
|
||||
})
|
||||
|
||||
describe('when all goes well', function() {
|
||||
beforeEach(function() {
|
||||
describe('when all goes well', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.req.body.email = this.email
|
||||
@@ -726,16 +726,16 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send back a json response', function() {
|
||||
it('should send back a json response', function () {
|
||||
this.res.json.callCount.should.equal(1)
|
||||
return expect(this.res.json.lastCall.args[0].email).to.equal(this.email)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({
|
||||
@@ -747,7 +747,7 @@ describe('LaunchpadController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should have updated the user to make them an admin', function() {
|
||||
it('should have updated the user to make them an admin', function () {
|
||||
this.User.updateOne.callCount.should.equal(1)
|
||||
return this.User.updateOne
|
||||
.calledWith(
|
||||
@@ -760,7 +760,7 @@ describe('LaunchpadController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should have set a redirect in session', function() {
|
||||
it('should have set a redirect in session', function () {
|
||||
this.AuthenticationController.setRedirectInSession.callCount.should.equal(
|
||||
1
|
||||
)
|
||||
@@ -770,8 +770,8 @@ describe('LaunchpadController', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the authMethod is invalid', function() {
|
||||
beforeEach(function() {
|
||||
describe('when the authMethod is invalid', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = undefined
|
||||
this.req.body.email = this.email
|
||||
@@ -789,24 +789,24 @@ describe('LaunchpadController', function() {
|
||||
)(this.req, this.res, this.next)
|
||||
})
|
||||
|
||||
it('should send a 403 response', function() {
|
||||
it('should send a 403 response', function () {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(403).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not check for existing admins', function() {
|
||||
it('should not check for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when no email is supplied', function() {
|
||||
beforeEach(function() {
|
||||
describe('when no email is supplied', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = undefined
|
||||
this.req.body.email = this.email
|
||||
@@ -826,24 +826,24 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send a 400 response', function() {
|
||||
it('should send a 400 response', function () {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(400).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not check for existing admins', function() {
|
||||
it('should not check for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(0)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when there are already existing admins', function() {
|
||||
beforeEach(function() {
|
||||
describe('when there are already existing admins', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, true)
|
||||
this.email = 'someone@example.com'
|
||||
this.req.body.email = this.email
|
||||
@@ -863,20 +863,20 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should send a 403 response', function() {
|
||||
it('should send a 403 response', function () {
|
||||
this.res.sendStatus.callCount.should.equal(1)
|
||||
return this.res.sendStatus.calledWith(403).should.equal(true)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when checking admins produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when checking admins produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, new Error('woops'))
|
||||
this.email = 'someone@example.com'
|
||||
this.req.body.email = this.email
|
||||
@@ -896,24 +896,24 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should not call registerNewUser', function() {
|
||||
it('should not call registerNewUser', function () {
|
||||
return this.UserRegistrationHandler.registerNewUser.callCount.should.equal(
|
||||
0
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when registerNewUser produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when registerNewUser produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.req.body.email = this.email
|
||||
@@ -935,16 +935,16 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({
|
||||
@@ -956,13 +956,13 @@ describe('LaunchpadController', function() {
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should not call update', function() {
|
||||
it('should not call update', function () {
|
||||
return this.User.updateOne.callCount.should.equal(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('when user update produces an error', function() {
|
||||
beforeEach(function() {
|
||||
describe('when user update produces an error', function () {
|
||||
beforeEach(function () {
|
||||
this._atLeastOneAdminExists.callsArgWith(0, null, false)
|
||||
this.email = 'someone@example.com'
|
||||
this.req.body.email = this.email
|
||||
@@ -984,16 +984,16 @@ describe('LaunchpadController', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should call next with an error', function() {
|
||||
it('should call next with an error', function () {
|
||||
this.next.callCount.should.equal(1)
|
||||
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
|
||||
})
|
||||
|
||||
it('should have checked for existing admins', function() {
|
||||
it('should have checked for existing admins', function () {
|
||||
return this._atLeastOneAdminExists.callCount.should.equal(1)
|
||||
})
|
||||
|
||||
it('should have called registerNewUser', function() {
|
||||
it('should have called registerNewUser', function () {
|
||||
this.UserRegistrationHandler.registerNewUser.callCount.should.equal(1)
|
||||
return this.UserRegistrationHandler.registerNewUser
|
||||
.calledWith({
|
||||
|
||||
Reference in New Issue
Block a user