Merge pull request #1899 from overleaf/spd-implicit-return-tests

Decaf cleanup: Remove implicit return from 'it' and 'describe' in tests

GitOrigin-RevId: f297820e6212dddc0d60697a2fe1612ef27403b6
This commit is contained in:
Simon Detheridge
2019-06-21 13:58:57 +00:00
committed by sharelatex
parent 6fc507aea3
commit 757ae39487
170 changed files with 1691 additions and 1691 deletions
@@ -43,7 +43,7 @@ describe('AnnouncementsHandler', function() {
}))
})
return describe('getUnreadAnnouncements', function() {
describe('getUnreadAnnouncements', function() {
beforeEach(function() {
this.stubbedAnnouncements = [
{
@@ -178,7 +178,7 @@ describe('AnnouncementsHandler', function() {
.returns(this.stubbedDomainSpecificAnn))
})
return it('should insert the domain specific in the correct place', function(done) {
it('should insert the domain specific in the correct place', function(done) {
this.AnalyticsManager.getLastOccurrence.callsArgWith(2, null, [])
return this.handler.getUnreadAnnouncements(
this.user,
@@ -194,7 +194,7 @@ describe('AnnouncementsHandler', function() {
})
})
return describe('_domainSpecificAnnouncements', function() {
describe('_domainSpecificAnnouncements', function() {
beforeEach(function() {
return (this.settings.domainAnnouncements = [
{
@@ -233,7 +233,7 @@ describe('AnnouncementsHandler', function() {
return done()
})
return it('should match on domain', function(done) {
it('should match on domain', function(done) {
this.settings.domainAnnouncements[2].domains = ['yahoo.com']
const result = this.handler._domainSpecificAnnouncements(
'someone@gmail.com'
@@ -108,7 +108,7 @@ describe('AuthenticationController', function() {
return this.stub.restore()
})
return it('should do the right thing in all cases', function() {
it('should do the right thing in all cases', function() {
this.AuthenticationController.getLoggedInUserId.returns('some_id')
expect(this.AuthenticationController.isUserLoggedIn(this.req)).to.equal(
true
@@ -140,7 +140,7 @@ describe('AuthenticationController', function() {
return (this.req.session.user = this.user)
})
return it('should update the right properties', function() {
it('should update the right properties', function() {
this.AuthenticationController.setInSessionUser(this.req, {
first_name: 'new_first_name',
email: 'new_email'
@@ -183,7 +183,7 @@ describe('AuthenticationController', function() {
return this.passport.authenticate.callsArgWith(1, this.err)
})
return it('should return next with an error', function() {
it('should return next with an error', function() {
this.AuthenticationController.passportLogin(
this.req,
this.res,
@@ -208,7 +208,7 @@ describe('AuthenticationController', function() {
return delete this.req.session.postLoginRedirect
})
return it('should call finishLogin', function() {
it('should call finishLogin', function() {
this.AuthenticationController.passportLogin(
this.req,
this.res,
@@ -221,7 +221,7 @@ describe('AuthenticationController', function() {
})
})
return describe('when authenticate does not produce a user', function() {
describe('when authenticate does not produce a user', function() {
beforeEach(function() {
this.info = { text: 'a', type: 'b' }
return this.passport.authenticate.callsArgWith(
@@ -243,7 +243,7 @@ describe('AuthenticationController', function() {
)
})
return it('should not send a json response with redirect', function() {
it('should not send a json response with redirect', function() {
this.AuthenticationController.passportLogin(
this.req,
this.res,
@@ -304,7 +304,7 @@ describe('AuthenticationController', function() {
})
})
return describe('when req.session.save produces an error', function() {
describe('when req.session.save produces an error', function() {
beforeEach(function() {
return (this.req.session.save = sinon
.stub()
@@ -319,7 +319,7 @@ describe('AuthenticationController', function() {
})
})
return it('should not call UserSessionsManager.trackSession', function(done) {
it('should not call UserSessionsManager.trackSession', function(done) {
return this.call(err => {
this.UserSessionsManager.trackSession.callCount.should.equal(0)
return done()
@@ -339,7 +339,7 @@ describe('AuthenticationController', function() {
return expect(user).to.deep.equal({ _id: 'one' })
})
return it('should work with legacy sessions', function() {
it('should work with legacy sessions', function() {
this.req.session = { user: { _id: 'one' } }
const user = this.AuthenticationController.getSessionUser(this.req)
return expect(user).to.deep.equal({ _id: 'one' })
@@ -369,7 +369,7 @@ describe('AuthenticationController', function() {
.callsArgWith(3, null, [null, { redir: '/somewhere' }, null]))
})
return it('should stop early and call done with this info object', function(done) {
it('should stop early and call done with this info object', function(done) {
this.AuthenticationController.doPassportLogin(
this.req,
this.req.body.email,
@@ -394,7 +394,7 @@ describe('AuthenticationController', function() {
)
})
return it('should block the request if the limit has been exceeded', function(done) {
it('should block the request if the limit has been exceeded', function(done) {
this.AuthenticationController.doPassportLogin(
this.req,
this.req.body.email,
@@ -429,7 +429,7 @@ describe('AuthenticationController', function() {
.should.equal(true)
})
return it("should establish the user's session", function() {
it("should establish the user's session", function() {
return this.cb.calledWith(null, this.user).should.equal(true)
})
})
@@ -484,14 +484,14 @@ describe('AuthenticationController', function() {
.should.equal(true)
})
return it('should track the login event', function() {
it('should track the login event', function() {
return this.AnalyticsManager.recordEvent
.calledWith(this.user._id, 'user-logged-in')
.should.equal(true)
})
})
return describe('when the user is not authenticated', function() {
describe('when the user is not authenticated', function() {
beforeEach(function() {
this.LoginRateLimiter.processLoginRequest.callsArgWith(1, null, true)
this.AuthenticationManager.authenticate = sinon
@@ -529,7 +529,7 @@ describe('AuthenticationController', function() {
)
})
return it('should log the failed login', function() {
it('should log the failed login', function() {
return this.logger.log
.calledWith({ email: this.email.toLowerCase() }, 'failed log in')
.should.equal(true)
@@ -573,7 +573,7 @@ describe('AuthenticationController', function() {
return expect(result).to.equal(null)
})
return it('should return null if there is no req', function() {
it('should return null if there is no req', function() {
this.req = {}
const result = this.AuthenticationController.getLoggedInUserId(this.req)
return expect(result).to.equal(null)
@@ -600,12 +600,12 @@ describe('AuthenticationController', function() {
return this.middleware(this.req, this.res, this.next)
})
return it('should call the next method in the chain', function() {
it('should call the next method in the chain', function() {
return this.next.called.should.equal(true)
})
})
return describe('when the user is not logged in', function() {
describe('when the user is not logged in', function() {
beforeEach(function() {
this.req.session = {}
this.AuthenticationController._redirectToLoginOrRegisterPage = sinon.stub()
@@ -613,7 +613,7 @@ describe('AuthenticationController', function() {
return this.middleware(this.req, this.res, this.next)
})
return it('should redirect to the register or login page', function() {
it('should redirect to the register or login page', function() {
return this.AuthenticationController._redirectToLoginOrRegisterPage
.calledWith(this.req, this.res)
.should.equal(true)
@@ -697,7 +697,7 @@ describe('AuthenticationController', function() {
)
})
return it('should call next() directly', function() {
it('should call next() directly', function() {
return this.next.called.should.equal(true)
})
})
@@ -714,7 +714,7 @@ describe('AuthenticationController', function() {
)
})
return it('should call next() directly', function() {
it('should call next() directly', function() {
return this.next.called.should.equal(true)
})
})
@@ -729,7 +729,7 @@ describe('AuthenticationController', function() {
)
})
return it('should pass the request onto httpAuth', function() {
it('should pass the request onto httpAuth', function() {
return this.AuthenticationController.httpAuth
.calledWith(this.req, this.res, this.next)
.should.equal(true)
@@ -746,12 +746,12 @@ describe('AuthenticationController', function() {
)
})
return it('should call next() directly', function() {
it('should call next() directly', function() {
return this.next.called.should.equal(true)
})
})
return describe('with no login credentials', function() {
describe('with no login credentials', function() {
beforeEach(function() {
this.req.session = {}
return this.AuthenticationController.requireGlobalLogin(
@@ -765,7 +765,7 @@ describe('AuthenticationController', function() {
return this.setRedirect.callCount.should.equal(1)
})
return it('should redirect to the /login page', function() {
it('should redirect to the /login page', function() {
return this.res.redirectedTo.should.equal('/login')
})
})
@@ -788,7 +788,7 @@ describe('AuthenticationController', function() {
return this.middleware(this.req, this.res, this.next)
})
return it('should redirect to the login page', function() {
it('should redirect to the login page', function() {
this.AuthenticationController._redirectToRegisterPage
.calledWith(this.req, this.res)
.should.equal(false)
@@ -804,7 +804,7 @@ describe('AuthenticationController', function() {
return this.middleware(this.req, this.res, this.next)
})
return it('should redirect to the register page', function() {
it('should redirect to the register page', function() {
this.AuthenticationController._redirectToRegisterPage
.calledWith(this.req, this.res)
.should.equal(true)
@@ -814,13 +814,13 @@ describe('AuthenticationController', function() {
})
})
return describe('they have been invited to a project', function() {
describe('they have been invited to a project', function() {
beforeEach(function() {
this.req.query.project_name = 'something'
return this.middleware(this.req, this.res, this.next)
})
return it('should redirect to the register page', function() {
it('should redirect to the register page', function() {
this.AuthenticationController._redirectToRegisterPage
.calledWith(this.req, this.res)
.should.equal(true)
@@ -848,7 +848,7 @@ describe('AuthenticationController', function() {
return this.res.redirectedTo.should.equal('/register?extra_query=foo')
})
return it('should log out a message', function() {
it('should log out a message', function() {
return this.logger.log
.calledWith(
{ url: this.url },
@@ -868,7 +868,7 @@ describe('AuthenticationController', function() {
)
})
return it('should redirect to the register page with a query string attached', function() {
it('should redirect to the register page with a query string attached', function() {
this.req.session.postLoginRedirect.should.equal(
'/target/url?extra_query=foo'
)
@@ -900,7 +900,7 @@ describe('AuthenticationController', function() {
].should.equal(1)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -914,7 +914,7 @@ describe('AuthenticationController', function() {
return this.Metrics.inc.calledWith('user.login.failed').should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -956,7 +956,7 @@ describe('AuthenticationController', function() {
return (this.req = { session: {} })
})
return it('should not set the redirect', function() {
it('should not set the redirect', function() {
this.AuthenticationController.setRedirectInSession(
this.req,
'/something.png'
@@ -965,12 +965,12 @@ describe('AuthenticationController', function() {
})
})
return describe('with a js path', function() {
describe('with a js path', function() {
beforeEach(function() {
return (this.req = { session: {} })
})
return it('should not set the redirect', function() {
it('should not set the redirect', function() {
this.AuthenticationController.setRedirectInSession(
this.req,
'/js/something.js'
@@ -995,7 +995,7 @@ describe('AuthenticationController', function() {
).to.be.null
})
return it('handle null values', function() {
it('handle null values', function() {
this.req = { session: {} }
return expect(
this.AuthenticationController._getRedirectFromSession(this.req)
@@ -1033,13 +1033,13 @@ describe('AuthenticationController', function() {
return (this.req = { session: { postLoginRedirect: '/a?b=c' } })
})
return it('should remove the redirect property from session', function() {
it('should remove the redirect property from session', function() {
this.AuthenticationController._clearRedirectFromSession(this.req)
return expect(this.req.session.postLoginRedirect).to.equal(undefined)
})
})
return describe('finishLogin', function() {
describe('finishLogin', function() {
// - get redirect
// - async handlers
// - afterLoginSessionSetup
@@ -1151,7 +1151,7 @@ describe('AuthenticationController', function() {
return (this.res.redirect = sinon.stub())
})
return it('should issue a plain redirect', function() {
it('should issue a plain redirect', function() {
this.AuthenticationController.finishLogin(
this.user,
this.req,
@@ -1164,12 +1164,12 @@ describe('AuthenticationController', function() {
})
})
return describe('when user is flagged to reconfirm', function() {
describe('when user is flagged to reconfirm', function() {
beforeEach(function() {
this.req.session = {}
return (this.user.must_reconfirm = true)
})
return it('should redirect to reconfirm page', function() {
it('should redirect to reconfirm page', function() {
this.AuthenticationController.finishLogin(
this.user,
this.req,
@@ -87,12 +87,12 @@ describe('AuthenticationManager', function() {
.should.equal(true)
})
return it('should return the user', function() {
it('should return the user', function() {
return this.callback.calledWith(null, this.user).should.equal(true)
})
})
return describe('when the encrypted passwords do not match', function() {
describe('when the encrypted passwords do not match', function() {
beforeEach(function() {
return this.AuthenticationManager.authenticate(
{ email: this.email },
@@ -101,13 +101,13 @@ describe('AuthenticationManager', function() {
)
})
return it('should not return the user', function() {
it('should not return the user', function() {
return this.callback.calledWith(null, null).should.equal(true)
})
})
})
return describe('setUserPasswordInV2', function() {
describe('setUserPasswordInV2', function() {
beforeEach(function() {
this.user = {
_id: '5c8791477192a80b5e76ca7e',
@@ -130,7 +130,7 @@ describe('AuthenticationManager', function() {
)
})
return it('should set the hashed password', function(done) {
it('should set the hashed password', function(done) {
return this.AuthenticationManager.setUserPasswordInV2(
this.user._id,
'testpassword',
@@ -189,7 +189,7 @@ describe('AuthenticationManager', function() {
.should.equal(true)
})
return it('should return the user', function() {
it('should return the user', function() {
return this.callback.calledWith(null, this.user).should.equal(true)
})
})
@@ -203,7 +203,7 @@ describe('AuthenticationManager', function() {
)
})
return it('should not return the user', function() {
it('should not return the user', function() {
return this.callback.calledWith(null, null).should.equal(true)
})
})
@@ -248,12 +248,12 @@ describe('AuthenticationManager', function() {
.should.equal(true)
})
return it('should return the user', function() {
it('should return the user', function() {
return this.callback.calledWith(null, this.user).should.equal(true)
})
})
return describe('when the hashed password matches but the number of rounds is too low, but upgrades disabled', function() {
describe('when the hashed password matches but the number of rounds is too low, but upgrades disabled', function() {
beforeEach(function(done) {
this.settings.security.disableBcryptRoundsUpgrades = true
this.user.hashedPassword = this.hashedPassword = 'asdfjadflasdf'
@@ -282,13 +282,13 @@ describe('AuthenticationManager', function() {
.should.equal(false)
})
return it('should return the user', function() {
it('should return the user', function() {
return this.callback.calledWith(null, this.user).should.equal(true)
})
})
})
return describe('when the user does not exist in the database', function() {
describe('when the user does not exist in the database', function() {
beforeEach(function() {
this.User.findOne = sinon.stub().callsArgWith(1, null, null)
return this.AuthenticationManager.authenticate(
@@ -298,7 +298,7 @@ describe('AuthenticationManager', function() {
)
})
return it('should not return a user', function() {
it('should not return a user', function() {
return this.callback.calledWith(null, null).should.equal(true)
})
})
@@ -313,14 +313,14 @@ describe('AuthenticationManager', function() {
return expect(result).to.equal(null)
}))
return describe('invalid', function() {
describe('invalid', function() {
it('should return validation error object for no email', function() {
const result = this.AuthenticationManager.validateEmail('')
expect(result).to.not.equal(null)
return expect(result.message).to.equal('email not valid')
})
return it('should return validation error object for invalid', function() {
it('should return validation error object for invalid', function() {
const result = this.AuthenticationManager.validateEmail('notanemail')
expect(result).to.not.equal(null)
return expect(result.message).to.equal('email not valid')
@@ -359,7 +359,7 @@ describe('AuthenticationManager', function() {
).to.eql({ message: 'password is too long' })
})
return it('should accept passwords that are a good length', function() {
it('should accept passwords that are a good length', function() {
return expect(
this.AuthenticationManager.validatePassword('l337h4x0r')
).to.equal(null)
@@ -394,14 +394,14 @@ describe('AuthenticationManager', function() {
).to.eql({ message: 'password is too long' })
})
return it('should accept passwords of exactly maximum length', function() {
it('should accept passwords of exactly maximum length', function() {
return expect(
this.AuthenticationManager.validatePassword('0123456789ab')
).to.equal(null)
})
})
return describe('when the maximum password length is set to >72 characters in settings', function() {
describe('when the maximum password length is set to >72 characters in settings', function() {
beforeEach(function() {
return (this.settings.passwordStrengthOptions = {
length: {
@@ -410,7 +410,7 @@ describe('AuthenticationManager', function() {
})
})
return it('should still reject passwords > 72 characters in length', function() {
it('should still reject passwords > 72 characters in length', function() {
return expect(
this.AuthenticationManager.validatePassword(this.longPassword)
).to.eql({ message: 'password is too long' })
@@ -418,7 +418,7 @@ describe('AuthenticationManager', function() {
})
})
return describe('allowed characters', function() {
describe('allowed characters', function() {
describe('with the default settings for allowed characters', function() {
it('should allow passwords with valid characters', function() {
expect(
@@ -433,7 +433,7 @@ describe('AuthenticationManager', function() {
).to.equal(null)
})
return it('should not allow passwords with invalid characters', function() {
it('should not allow passwords with invalid characters', function() {
return expect(
this.AuthenticationManager.validatePassword(
'correct horse battery staple'
@@ -459,7 +459,7 @@ describe('AuthenticationManager', function() {
).to.equal(null)
})
return it('should disallow passwords with invalid characters', function() {
it('should disallow passwords with invalid characters', function() {
return expect(
this.AuthenticationManager.validatePassword(
'1234567890@#$%^&*()-_=+[]{};:<>/?!£€.,'
@@ -468,14 +468,14 @@ describe('AuthenticationManager', function() {
})
})
return describe('when allowAnyChars is set', function() {
describe('when allowAnyChars is set', function() {
beforeEach(function() {
return (this.settings.passwordStrengthOptions = {
allowAnyChars: true
})
})
return it('should allow any characters', function() {
it('should allow any characters', function() {
expect(
this.AuthenticationManager.validatePassword(
'correct horse battery staple'
@@ -491,7 +491,7 @@ describe('AuthenticationManager', function() {
})
})
return describe('setUserPassword', function() {
describe('setUserPassword', function() {
beforeEach(function() {
this.user_id = ObjectId()
this.password = 'banana'
@@ -523,7 +523,7 @@ describe('AuthenticationManager', function() {
)
})
return it('should not start the bcrypt process', function(done) {
it('should not start the bcrypt process', function(done) {
return this.AuthenticationManager.setUserPassword(
this.user_id,
this.password,
@@ -558,7 +558,7 @@ describe('AuthenticationManager', function() {
)
})
return it('should not start the bcrypt process', function(done) {
it('should not start the bcrypt process', function(done) {
return this.AuthenticationManager.setUserPassword(
this.user_id,
this.password,
@@ -571,7 +571,7 @@ describe('AuthenticationManager', function() {
})
})
return describe('password set attempt', function() {
describe('password set attempt', function() {
describe('with SL user in SL', function() {
beforeEach(function() {
this.UserGetter.getUser = sinon
@@ -612,7 +612,7 @@ describe('AuthenticationManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -632,7 +632,7 @@ describe('AuthenticationManager', function() {
}
)
})
return it('should error', function() {
it('should error', function() {
return this.callback
.calledWith(new Errors.SLInV2Error('Password Reset Attempt'))
.should.equal(true)
@@ -653,14 +653,14 @@ describe('AuthenticationManager', function() {
}
)
})
return it('should error', function() {
it('should error', function() {
return this.callback
.calledWith(new Errors.NotInV2Error('Password Reset Attempt'))
.should.equal(true)
})
})
return describe('with v2 user in v2', function() {
describe('with v2 user in v2', function() {
beforeEach(function(done) {
this.settings.overleaf = true
this.UserGetter.getUser = sinon
@@ -676,7 +676,7 @@ describe('AuthenticationManager', function() {
}
)
})
return it('should set the password in v2', function() {
it('should set the password in v2', function() {
return this.callback.calledWith(null, true).should.equal(true)
})
})
@@ -71,7 +71,7 @@ describe('AuthorizationManager', function() {
)
})
return it("should return the user's privilege level", function() {
it("should return the user's privilege level", function() {
return this.callback
.calledWith(null, 'readOnly', false, false)
.should.equal(true)
@@ -94,7 +94,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -117,14 +117,14 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the user as an owner', function() {
it('should return the user as an owner', function() {
return this.callback
.calledWith(null, 'owner', false, true)
.should.equal(true)
})
})
return describe('with no user (anonymous)', function() {
describe('with no user (anonymous)', function() {
describe('when the token is not valid', function() {
beforeEach(function() {
this.TokenAccessHandler.isValidToken = sinon
@@ -157,7 +157,7 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -198,14 +198,14 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should deny access', function() {
it('should deny access', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
})
})
return describe('when read-write-sharing is enabled', function() {
describe('when read-write-sharing is enabled', function() {
beforeEach(function() {
this.TokenAccessHandler.ANONYMOUS_READ_AND_WRITE_ENABLED = true
this.TokenAccessHandler.isValidToken = sinon
@@ -238,7 +238,7 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should give read-write access', function() {
it('should give read-write access', function() {
return this.callback
.calledWith(null, 'readAndWrite', false)
.should.equal(true)
@@ -246,7 +246,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('when the token is valid for read-only', function() {
describe('when the token is valid for read-only', function() {
beforeEach(function() {
this.TokenAccessHandler.isValidToken = sinon
.stub()
@@ -278,7 +278,7 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should give read-only access', function() {
it('should give read-only access', function() {
return this.callback
.calledWith(null, 'readOnly', false)
.should.equal(true)
@@ -310,7 +310,7 @@ describe('AuthorizationManager', function() {
)
})
return it("should return the user's privilege level", function() {
it("should return the user's privilege level", function() {
return this.callback
.calledWith(null, 'readOnly', false, false)
.should.equal(true)
@@ -333,7 +333,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -356,14 +356,14 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the user as an owner', function() {
it('should return the user as an owner', function() {
return this.callback
.calledWith(null, 'owner', false, true)
.should.equal(true)
})
})
return describe('with no user (anonymous)', function() {
describe('with no user (anonymous)', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject(
null,
@@ -385,7 +385,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -416,7 +416,7 @@ describe('AuthorizationManager', function() {
)
})
return it("should return the user's privilege level", function() {
it("should return the user's privilege level", function() {
return this.callback
.calledWith(null, 'readOnly', false)
.should.equal(true)
@@ -439,7 +439,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the public privilege level', function() {
it('should return the public privilege level', function() {
return this.callback
.calledWith(null, 'readAndWrite', true)
.should.equal(true)
@@ -462,14 +462,14 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the user as an owner', function() {
it('should return the user as an owner', function() {
return this.callback
.calledWith(null, 'owner', false)
.should.equal(true)
})
})
return describe('with no user (anonymous)', function() {
describe('with no user (anonymous)', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject(
null,
@@ -491,7 +491,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the public privilege level', function() {
it('should return the public privilege level', function() {
return this.callback
.calledWith(null, 'readAndWrite', true)
.should.equal(true)
@@ -506,7 +506,7 @@ describe('AuthorizationManager', function() {
.yields(null, null)
})
return it('should return a NotFoundError', function() {
it('should return a NotFoundError', function() {
return this.AuthorizationManager.getPrivilegeLevelForProject(
this.user_id,
this.project_id,
@@ -516,7 +516,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('when the project id is not valid', function() {
describe('when the project id is not valid', function() {
beforeEach(function() {
this.AuthorizationManager.isUserSiteAdmin
.withArgs(this.user_id)
@@ -526,7 +526,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly')
})
return it('should return a error', function(done) {
it('should return a error', function(done) {
return this.AuthorizationManager.getPrivilegeLevelForProject(
undefined,
'not project id',
@@ -553,7 +553,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -573,7 +573,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -593,7 +593,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -606,14 +606,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -639,7 +639,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -659,7 +659,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -679,7 +679,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -692,14 +692,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -725,7 +725,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -745,7 +745,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -765,7 +765,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', true)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -785,7 +785,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -798,14 +798,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -831,7 +831,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -851,7 +851,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -871,7 +871,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -884,14 +884,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -905,7 +905,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('isUserSiteAdmin', function() {
describe('isUserSiteAdmin', function() {
beforeEach(function() {
return (this.User.findOne = sinon.stub())
})
@@ -917,7 +917,7 @@ describe('AuthorizationManager', function() {
.yields(null, { isAdmin: true })
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(this.user_id, function(
error,
isAdmin
@@ -935,7 +935,7 @@ describe('AuthorizationManager', function() {
.yields(null, { isAdmin: false })
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(this.user_id, function(
error,
isAdmin
@@ -953,7 +953,7 @@ describe('AuthorizationManager', function() {
.yields(null, null)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(this.user_id, function(
error,
isAdmin
@@ -964,7 +964,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('when no user is passed', () =>
describe('when no user is passed', () =>
it('should return false', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(
null,
@@ -85,7 +85,7 @@ describe('AuthorizationMiddleware', function() {
)
})
return it('should fall back to null', function(done) {
it('should fall back to null', function(done) {
this.AuthenticationController.getLoggedInUserId = sinon
.stub()
.returns(null)
@@ -122,7 +122,7 @@ describe('AuthorizationMiddleware', function() {
return (this.req.params = {})
})
return it('should return an error to next', function() {
it('should return an error to next', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -146,7 +146,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -156,14 +156,14 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
return this.AuthorizationManager[managerMethod]
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -186,7 +186,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -196,7 +196,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
return this.AuthorizationManager[managerMethod]
@@ -204,7 +204,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -218,13 +218,13 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('with malformed project id', function() {
describe('with malformed project id', function() {
beforeEach(function() {
this.req.params = { project_id: 'blah' }
return (this.ObjectId.isValid = sinon.stub().returns(false))
})
return it('should return a not found error', function(done) {
it('should return a not found error', function(done) {
return this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -258,7 +258,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -268,14 +268,14 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
return this.AuthorizationManager.isUserSiteAdmin
.withArgs(this.user_id)
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -289,7 +289,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('with anonymous user', function() {
describe('with anonymous user', function() {
describe('when user has permission', function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
@@ -298,7 +298,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -308,7 +308,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
return this.AuthorizationManager.isUserSiteAdmin
@@ -316,7 +316,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -331,7 +331,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('ensureUserCanReadMultipleProjects', function() {
describe('ensureUserCanReadMultipleProjects', function() {
beforeEach(function() {
this.AuthorizationManager.canUserReadProject = sinon.stub()
this.AuthorizationMiddleware.redirectToRestricted = sinon.stub()
@@ -355,7 +355,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -365,7 +365,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission to access one of the projects", function() {
describe("when user doesn't have permission to access one of the projects", function() {
beforeEach(function() {
this.AuthorizationManager.canUserReadProject
.withArgs(this.user_id, 'project1', this.token)
@@ -375,7 +375,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -389,7 +389,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('with anonymous user', () =>
describe('with anonymous user', () =>
describe('when user has permission', function() {
describe('when user has permission to access all projects', function() {
beforeEach(function() {
@@ -402,7 +402,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -412,7 +412,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission to access one of the projects", function() {
describe("when user doesn't have permission to access one of the projects", function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
this.AuthorizationManager.canUserReadProject
@@ -423,7 +423,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -94,7 +94,7 @@ describe('BetaProgramController', function() {
return this.BetaProgramHandler.optIn.callCount.should.equal(1)
})
return describe('when BetaProgramHandler.opIn produces an error', function() {
describe('when BetaProgramHandler.opIn produces an error', function() {
beforeEach(function() {
return this.BetaProgramHandler.optIn.callsArgWith(1, new Error('woops'))
})
@@ -104,7 +104,7 @@ describe('BetaProgramController', function() {
return this.res.redirect.callCount.should.equal(0)
})
return it('should produce an error', function() {
it('should produce an error', function() {
this.BetaProgramController.optIn(this.req, this.res, this.next)
this.next.callCount.should.equal(1)
return this.next.firstCall.args[0].should.be.instanceof(Error)
@@ -140,7 +140,7 @@ describe('BetaProgramController', function() {
return this.BetaProgramHandler.optOut.callCount.should.equal(1)
})
return describe('when BetaProgramHandler.optOut produces an error', function() {
describe('when BetaProgramHandler.optOut produces an error', function() {
beforeEach(function() {
return this.BetaProgramHandler.optOut.callsArgWith(
1,
@@ -153,7 +153,7 @@ describe('BetaProgramController', function() {
return this.res.redirect.callCount.should.equal(0)
})
return it('should produce an error', function() {
it('should produce an error', function() {
this.BetaProgramController.optOut(this.req, this.res, this.next)
this.next.callCount.should.equal(1)
return this.next.firstCall.args[0].should.be.instanceof(Error)
@@ -161,7 +161,7 @@ describe('BetaProgramController', function() {
})
})
return describe('optInPage', function() {
describe('optInPage', function() {
beforeEach(function() {
return this.UserGetter.getUser.callsArgWith(1, null, this.user)
})
@@ -173,7 +173,7 @@ describe('BetaProgramController', function() {
return args[0].should.equal('beta_program/opt_in')
})
return describe('when UserGetter.getUser produces an error', function() {
describe('when UserGetter.getUser produces an error', function() {
beforeEach(function() {
return this.UserGetter.getUser.callsArgWith(1, new Error('woops'))
})
@@ -183,7 +183,7 @@ describe('BetaProgramController', function() {
return this.res.render.callCount.should.equal(0)
})
return it('should produce an error', function() {
it('should produce an error', function() {
this.BetaProgramController.optInPage(this.req, this.res, this.next)
this.next.callCount.should.equal(1)
return this.next.firstCall.args[0].should.be.instanceof(Error)
@@ -80,12 +80,12 @@ describe('BetaProgramHandler', function() {
})
})
return describe('when user.save produces an error', function() {
describe('when user.save produces an error', function() {
beforeEach(function() {
return this.user.save.callsArgWith(0, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -95,7 +95,7 @@ describe('BetaProgramHandler', function() {
})
})
return describe('optOut', function() {
describe('optOut', function() {
beforeEach(function() {
this.user.betaProgram = true
return (this.call = callback => {
@@ -125,12 +125,12 @@ describe('BetaProgramHandler', function() {
})
})
return describe('when user.save produces an error', function() {
describe('when user.save produces an error', function() {
beforeEach(function() {
return this.user.save.callsArgWith(0, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -78,7 +78,7 @@ describe('BlogController', function() {
return this.BlogController.getPage(this.req, this.res)
})
return it('should proxy the image urls', function(done) {
it('should proxy the image urls', function(done) {
this.BlogController._directProxy = sinon.stub()
this.req.url = '/something.png'
this.BlogController.getPage(this.req, this.res)
@@ -89,7 +89,7 @@ describe('BlogController', function() {
})
})
return describe('getIndexPage', () =>
describe('getIndexPage', () =>
it('should change the url and send it to getPage', function(done) {
this.req.url = '/blog'
this.BlogController.getPage = function(req, res) {
@@ -54,7 +54,7 @@ describe('BrandVariationsHandler', function() {
})
})
return describe('getBrandVariationById', function() {
describe('getBrandVariationById', function() {
it('should call the callback with an error when the branding variation id is not provided', function(done) {
return this.BrandVariationsHandler.getBrandVariationById(
null,
@@ -95,7 +95,7 @@ describe('BrandVariationsHandler', function() {
)
})
return it('should transform relative URLs in v1 absolute ones', function(done) {
it('should transform relative URLs in v1 absolute ones', function(done) {
this.mockedBrandVariationDetails.logo_url = '/journal-logo.png'
this.V1Api.request.callsArgWith(
1,
@@ -72,12 +72,12 @@ describe('ChatApiHandler', function() {
.should.equal(true)
})
return it('should return the message from the post', function() {
it('should return the message from the post', function() {
return this.callback.calledWith(null, this.message).should.equal(true)
})
})
return describe('with a non-success status code', function() {
describe('with a non-success status code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 })
return this.ChatApiHandler.sendGlobalMessage(
@@ -88,7 +88,7 @@ describe('ChatApiHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
const error = new Error()
error.statusCode = 500
return this.callback.calledWith(error).should.equal(true)
@@ -96,7 +96,7 @@ describe('ChatApiHandler', function() {
})
})
return describe('getGlobalMessages', function() {
describe('getGlobalMessages', function() {
beforeEach(function() {
this.messages = [{ mock: 'message' }]
this.limit = 30
@@ -130,12 +130,12 @@ describe('ChatApiHandler', function() {
.should.equal(true)
})
return it('should return the messages from the request', function() {
it('should return the messages from the request', function() {
return this.callback.calledWith(null, this.messages).should.equal(true)
})
})
return describe('with failure error code', function() {
describe('with failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, null)
return this.ChatApiHandler.getGlobalMessages(
@@ -146,7 +146,7 @@ describe('ChatApiHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
const error = new Error()
error.statusCode = 500
return this.callback.calledWith(error).should.equal(true)
@@ -101,7 +101,7 @@ describe('ChatController', function() {
.should.equal(true)
})
return it('should return a 204 status code', function() {
it('should return a 204 status code', function() {
return this.res.send.calledWith(204).should.equal(true)
})
})
@@ -125,12 +125,12 @@ describe('ChatController', function() {
.should.equal(true)
})
return it('should return the messages', function() {
it('should return the messages', function() {
return this.res.json.calledWith(this.messages).should.equal(true)
})
})
return describe('_injectUserInfoIntoThreads', function() {
describe('_injectUserInfoIntoThreads', function() {
beforeEach(function() {
this.users = {
user_id_1: {
@@ -209,7 +209,7 @@ describe('ChatController', function() {
)
})
return it('should only need to look up each user once', function(done) {
it('should only need to look up each user once', function(done) {
return this.ChatController._injectUserInfoIntoThreads(
[
{
@@ -77,7 +77,7 @@ describe('CollaboratorsController', function() {
return this.res.sendStatus.calledWith(204).should.equal(true)
})
return it('should have called emitToRoom', function() {
it('should have called emitToRoom', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:membership:changed')
.should.equal(true)
@@ -109,12 +109,12 @@ describe('CollaboratorsController', function() {
.should.equal(true)
})
return it('should return a success code', function() {
it('should return a success code', function() {
return this.res.sendStatus.calledWith(204).should.equal(true)
})
})
return describe('getAllMembers', function() {
describe('getAllMembers', function() {
beforeEach(function() {
this.req.session = { user: { _id: (this.user_id = 'user-id-123') } }
this.req.params = { Project_id: this.project_id }
@@ -148,7 +148,7 @@ describe('CollaboratorsController', function() {
)
})
return describe('when CollaboratorsHandler.getAllInvitedMembers produces an error', function() {
describe('when CollaboratorsHandler.getAllInvitedMembers produces an error', function() {
beforeEach(function() {
this.res.json = sinon.stub()
this.next = sinon.stub()
@@ -167,7 +167,7 @@ describe('CollaboratorsController', function() {
return this.next.firstCall.args[0].should.be.instanceof(Error)
})
return it('should not produce a json response', function() {
it('should not produce a json response', function() {
return this.res.json.callCount.should.equal(0)
})
})
@@ -82,7 +82,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return an array of member ids with their privilege levels', function() {
it('should return an array of member ids with their privilege levels', function() {
return this.callback
.calledWith(null, [
{ id: 'owner-ref', privilegeLevel: 'owner', source: 'owner' },
@@ -111,12 +111,12 @@ describe('CollaboratorsHandler', function() {
})
})
return describe('with a missing project', function() {
describe('with a missing project', function() {
beforeEach(function() {
return (this.ProjectGetter.getProject = sinon.stub().yields(null, null))
})
return it('should return a NotFoundError', function(done) {
it('should return a NotFoundError', function(done) {
return this.CollaboratorHandler.getMemberIdsWithPrivilegeLevels(
this.project_id,
function(error) {
@@ -143,7 +143,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return the ids', function() {
it('should return the ids', function() {
return this.callback
.calledWith(null, ['member-id-1', 'member-id-2'])
.should.equal(true)
@@ -165,7 +165,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return the invited ids', function() {
it('should return the invited ids', function() {
return this.callback.calledWith(null, ['member-id-1']).should.equal(true)
})
})
@@ -224,7 +224,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return an array of members with their privilege levels', function() {
it('should return an array of members with their privilege levels', function() {
return this.callback
.calledWith(null, [
{ user: { _id: 'read-only-ref-1' }, privilegeLevel: 'readOnly' },
@@ -290,7 +290,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return an array of invited members with their privilege levels', function() {
it('should return an array of invited members with their privilege levels', function() {
return this.callback
.calledWith(null, [
{ user: { _id: 'read-only-ref-2' }, privilegeLevel: 'readOnly' },
@@ -354,7 +354,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return an array of token members with their privilege levels', function() {
it('should return an array of token members with their privilege levels', function() {
return this.callback
.calledWith(null, [
{ user: { _id: 'read-only-ref-1' }, privilegeLevel: 'readOnly' },
@@ -386,7 +386,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return false if the member has no privilege level', function(done) {
it('should return false if the member has no privilege level', function(done) {
return this.CollaboratorHandler.getMemberIdPrivilegeLevel(
'member-id-3',
this.project_id,
@@ -426,14 +426,14 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return true and the privilegeLevel', function() {
it('should return true and the privilegeLevel', function() {
return this.callback
.calledWith(null, true, 'readAndWrite')
.should.equal(true)
})
})
return describe('when user is not a member of the project', function() {
describe('when user is not a member of the project', function() {
beforeEach(function() {
this.CollaboratorHandler.getMemberIdsWithPrivilegeLevels
.withArgs(this.project_id)
@@ -445,7 +445,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback.calledWith(null, false, null).should.equal(true)
})
})
@@ -495,7 +495,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should call the callback with the projects', function() {
it('should call the callback with the projects', function() {
return this.callback
.calledWith(null, {
readAndWrite: [
@@ -526,7 +526,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should remove the user from mongo', function() {
it('should remove the user from mongo', function() {
return this.Project.update
.calledWith(
{
@@ -590,7 +590,7 @@ describe('CollaboratorsHandler', function() {
.should.equal(true)
})
return it('should add the user as a contact for the adding user', function() {
it('should add the user as a contact for the adding user', function() {
return this.ContactManager.addContact
.calledWith(this.adding_user_id, this.user_id)
.should.equal(true)
@@ -621,7 +621,7 @@ describe('CollaboratorsHandler', function() {
.should.equal(true)
})
return it('should flush the project to the TPDS', function() {
it('should flush the project to the TPDS', function() {
return this.ProjectEntityHandler.flushProjectToThirdPartyDataStore
.calledWith(this.project_id)
.should.equal(true)
@@ -639,7 +639,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback.calledWith(new Error()).should.equal(true)
})
})
@@ -656,12 +656,12 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should not add the user again', function() {
it('should not add the user again', function() {
return this.Project.update.called.should.equal(false)
})
})
return describe('with null adding_user_id', function() {
describe('with null adding_user_id', function() {
beforeEach(function() {
return this.CollaboratorHandler.addUserIdToProject(
this.project_id,
@@ -672,7 +672,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should not add the adding user as a contact', function() {
it('should not add the adding user as a contact', function() {
return this.ContactManager.addContact.called.should.equal(false)
})
})
@@ -708,7 +708,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should remove the user from each project', function() {
it('should remove the user from each project', function() {
const expectedProjects = [
'read-and-write-0',
'read-and-write-1',
@@ -793,7 +793,7 @@ describe('CollaboratorsHandler', function() {
)
})
return describe('when getMembersWithPrivileges produces an error', function() {
describe('when getMembersWithPrivileges produces an error', function() {
beforeEach(function() {
this.CollaboratorHandler.getInvitedMembersWithPrivilegeLevels = sinon
.stub()
@@ -834,7 +834,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should not call ProjectEditorHandler.buildOwnerAndMembersViews', function() {
it('should not call ProjectEditorHandler.buildOwnerAndMembersViews', function() {
return this.ProjectEditorHandler.buildOwnerAndMembersViews.callCount.should.equal(
0
)
@@ -875,7 +875,7 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should return false when the project is not found', function(done) {
it('should return false when the project is not found', function(done) {
this.project = null
this.Project.findOne = sinon.stub().callsArgWith(2, null, this.project)
return this.CollaboratorHandler.userIsTokenMember(
@@ -890,7 +890,7 @@ describe('CollaboratorsHandler', function() {
})
})
return describe('transferProjects', function() {
describe('transferProjects', function() {
beforeEach(function() {
this.from_user_id = 'from-user-id'
this.to_user_id = 'to-user-id'
@@ -1012,12 +1012,12 @@ describe('CollaboratorsHandler', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when flushing to TPDS fails', function() {
describe('when flushing to TPDS fails', function() {
beforeEach(function() {
this.ProjectEntityHandler.flushProjectToThirdPartyDataStore = sinon
.stub()
@@ -1033,7 +1033,7 @@ describe('CollaboratorsHandler', function() {
return this.logger.err.called.should.equal(true)
})
return it('should not return an error since it happens in the background', function() {
it('should not return an error since it happens in the background', function() {
this.callback.called.should.equal(true)
return this.callback.calledWith(new Error('oops')).should.equal(false)
})
@@ -107,7 +107,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should have called CollaboratorsInviteHandler.getAllInvites', function() {
it('should have called CollaboratorsInviteHandler.getAllInvites', function() {
this.CollaboratorsInviteHandler.getAllInvites.callCount.should.equal(1)
return this.CollaboratorsInviteHandler.getAllInvites
.calledWith(this.project_id)
@@ -115,7 +115,7 @@ describe('CollaboratorsInviteController', function() {
})
})
return describe('when CollaboratorsInviteHandler.getAllInvites produces an error', function() {
describe('when CollaboratorsInviteHandler.getAllInvites produces an error', function() {
beforeEach(function() {
this.CollaboratorsInviteHandler.getAllInvites = sinon
.stub()
@@ -127,7 +127,7 @@ describe('CollaboratorsInviteController', function() {
)
})
return it('should produce an error', function() {
it('should produce an error', function() {
this.next.callCount.should.equal(1)
return this.next.firstCall.args[0].should.be.instanceof(Error)
})
@@ -220,7 +220,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should have called emitToRoom', function() {
it('should have called emitToRoom', function() {
this.EditorRealTimeController.emitToRoom.callCount.should.equal(1)
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:membership:changed')
@@ -262,7 +262,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(false)
})
return it('should not have called inviteToProject', function() {
it('should not have called inviteToProject', function() {
return this.CollaboratorsInviteHandler.inviteToProject.callCount.should.equal(
0
)
@@ -301,7 +301,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(false)
})
return it('should not have called inviteToProject', function() {
it('should not have called inviteToProject', function() {
return this.CollaboratorsInviteHandler.inviteToProject.callCount.should.equal(
0
)
@@ -348,7 +348,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should have called inviteToProject', function() {
it('should have called inviteToProject', function() {
this.CollaboratorsInviteHandler.inviteToProject.callCount.should.equal(
1
)
@@ -398,7 +398,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should not have called inviteToProject', function() {
it('should not have called inviteToProject', function() {
return this.CollaboratorsInviteHandler.inviteToProject.callCount.should.equal(
0
)
@@ -437,7 +437,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should not have called inviteToProject', function() {
it('should not have called inviteToProject', function() {
return this.CollaboratorsInviteHandler.inviteToProject.callCount.should.equal(
0
)
@@ -489,14 +489,14 @@ describe('CollaboratorsInviteController', function() {
)
})
return it('should not have called emitToRoom', function() {
it('should not have called emitToRoom', function() {
return this.EditorRealTimeController.emitToRoom.callCount.should.equal(
0
)
})
})
return describe('when _checkRateLimit returns false', function() {
describe('when _checkRateLimit returns false', function() {
beforeEach(function() {
this.CollaboratorsInviteController._checkShouldInviteEmail = sinon
.stub()
@@ -524,7 +524,7 @@ describe('CollaboratorsInviteController', function() {
)
})
return it('should not call emitToRoom', function() {
it('should not call emitToRoom', function() {
return this.EditorRealTimeController.emitToRoom.called.should.equal(
false
)
@@ -627,7 +627,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should call ProjectGetter.getProject', function() {
it('should call ProjectGetter.getProject', function() {
this.ProjectGetter.getProject.callCount.should.equal(1)
return this.ProjectGetter.getProject
.calledWith(this.project_id)
@@ -677,7 +677,7 @@ describe('CollaboratorsInviteController', function() {
return this.UserGetter.getUser.callCount.should.equal(0)
})
return it('should not call ProjectGetter.getProject', function() {
it('should not call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(0)
})
})
@@ -718,7 +718,7 @@ describe('CollaboratorsInviteController', function() {
return this.UserGetter.getUser.callCount.should.equal(0)
})
return it('should not call ProjectGetter.getProject', function() {
it('should not call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(0)
})
})
@@ -764,7 +764,7 @@ describe('CollaboratorsInviteController', function() {
return this.UserGetter.getUser.callCount.should.equal(0)
})
return it('should not call ProjectGetter.getProject', function() {
it('should not call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(0)
})
})
@@ -816,7 +816,7 @@ describe('CollaboratorsInviteController', function() {
return this.UserGetter.getUser.callCount.should.equal(0)
})
return it('should not call ProjectGetter.getProject', function() {
it('should not call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(0)
})
})
@@ -858,7 +858,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should not call ProjectGetter.getProject', function() {
it('should not call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(0)
})
})
@@ -906,7 +906,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should not call ProjectGetter.getProject', function() {
it('should not call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(0)
})
})
@@ -948,12 +948,12 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should call ProjectGetter.getProject', function() {
it('should call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(1)
})
})
return describe('when Project.getUser does not find a user', function() {
describe('when Project.getUser does not find a user', function() {
beforeEach(function() {
this.ProjectGetter.getProject.callsArgWith(2, null, null)
return this.CollaboratorsInviteController.viewInvite(
@@ -996,7 +996,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should call ProjectGetter.getProject', function() {
it('should call ProjectGetter.getProject', function() {
return this.ProjectGetter.getProject.callCount.should.equal(1)
})
})
@@ -1043,14 +1043,14 @@ describe('CollaboratorsInviteController', function() {
)
})
return it('should check the rate limit', function() {
it('should check the rate limit', function() {
return this.CollaboratorsInviteController._checkRateLimit.callCount.should.equal(
1
)
})
})
return describe('when resendInvite produces an error', function() {
describe('when resendInvite produces an error', function() {
beforeEach(function() {
this.err = new Error('woops')
this.CollaboratorsInviteHandler.resendInvite = sinon
@@ -1072,7 +1072,7 @@ describe('CollaboratorsInviteController', function() {
return this.next.calledWith(this.err).should.equal(true)
})
return it('should have called resendInvite', function() {
it('should have called resendInvite', function() {
return this.CollaboratorsInviteHandler.resendInvite.callCount.should.equal(
1
)
@@ -1117,7 +1117,7 @@ describe('CollaboratorsInviteController', function() {
)
})
return it('should have called emitToRoom', function() {
it('should have called emitToRoom', function() {
this.EditorRealTimeController.emitToRoom.callCount.should.equal(1)
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:membership:changed')
@@ -1125,7 +1125,7 @@ describe('CollaboratorsInviteController', function() {
})
})
return describe('when revokeInvite produces an error', function() {
describe('when revokeInvite produces an error', function() {
beforeEach(function() {
this.err = new Error('woops')
this.CollaboratorsInviteHandler.revokeInvite = sinon
@@ -1147,7 +1147,7 @@ describe('CollaboratorsInviteController', function() {
return this.next.calledWith(this.err).should.equal(true)
})
return it('should have called revokeInvite', function() {
it('should have called revokeInvite', function() {
return this.CollaboratorsInviteHandler.revokeInvite.callCount.should.equal(
1
)
@@ -1195,7 +1195,7 @@ describe('CollaboratorsInviteController', function() {
.should.equal(true)
})
return it('should have called emitToRoom', function() {
it('should have called emitToRoom', function() {
this.EditorRealTimeController.emitToRoom.callCount.should.equal(1)
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:membership:changed')
@@ -1203,7 +1203,7 @@ describe('CollaboratorsInviteController', function() {
})
})
return describe('when revokeInvite produces an error', function() {
describe('when revokeInvite produces an error', function() {
beforeEach(function() {
this.err = new Error('woops')
this.CollaboratorsInviteHandler.acceptInvite = sinon
@@ -1225,7 +1225,7 @@ describe('CollaboratorsInviteController', function() {
return this.next.calledWith(this.err).should.equal(true)
})
return it('should have called acceptInvite', function() {
it('should have called acceptInvite', function() {
return this.CollaboratorsInviteHandler.acceptInvite.callCount.should.equal(
1
)
@@ -1238,7 +1238,7 @@ describe('CollaboratorsInviteController', function() {
return (this.email = 'user@example.com')
})
return describe('when we should be restricting to existing accounts', function() {
describe('when we should be restricting to existing accounts', function() {
beforeEach(function() {
this.settings.restrictInvitesToExistingAccounts = true
return (this.call = callback => {
@@ -1257,7 +1257,7 @@ describe('CollaboratorsInviteController', function() {
.callsArgWith(2, null, this.user))
})
return it('should callback with `true`', function(done) {
it('should callback with `true`', function(done) {
return this.call((err, shouldAllow) => {
expect(err).to.equal(null)
expect(shouldAllow).to.equal(true)
@@ -1282,7 +1282,7 @@ describe('CollaboratorsInviteController', function() {
})
})
return it('should have called getUser', function(done) {
it('should have called getUser', function(done) {
return this.call((err, shouldAllow) => {
this.UserGetter.getUserByAnyEmail.callCount.should.equal(1)
this.UserGetter.getUserByAnyEmail
@@ -1293,7 +1293,7 @@ describe('CollaboratorsInviteController', function() {
})
})
return describe('when getUser produces an error', function() {
describe('when getUser produces an error', function() {
beforeEach(function() {
this.user = null
return (this.UserGetter.getUserByAnyEmail = sinon
@@ -1301,7 +1301,7 @@ describe('CollaboratorsInviteController', function() {
.callsArgWith(2, new Error('woops')))
})
return it('should callback with an error', function(done) {
it('should callback with an error', function(done) {
return this.call((err, shouldAllow) => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -1313,7 +1313,7 @@ describe('CollaboratorsInviteController', function() {
})
})
return describe('_checkRateLimit', function() {
describe('_checkRateLimit', function() {
beforeEach(function() {
this.settings.restrictInvitesToExistingAccounts = false
this.sendingUserId = '32312313'
@@ -1372,7 +1372,7 @@ describe('CollaboratorsInviteController', function() {
)
})
return it('should call rate limiter with 10 when user has no collaborators set', function(done) {
it('should call rate limiter with 10 when user has no collaborators set', function(done) {
this.LimitationsManager.allowedNumberOfCollaboratorsForUser
.withArgs(this.sendingUserId)
.yields(null)
@@ -125,12 +125,12 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when model.count produces an error', function() {
describe('when model.count produces an error', function() {
beforeEach(function() {
return this.ProjectInvite.count.callsArgWith(1, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, count) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -173,7 +173,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should have called ProjectInvite.find', function(done) {
it('should have called ProjectInvite.find', function(done) {
return this.call((err, invites) => {
this.ProjectInvite.find.callCount.should.equal(1)
this.ProjectInvite.find
@@ -184,12 +184,12 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when ProjectInvite.find produces an error', function() {
describe('when ProjectInvite.find produces an error', function() {
beforeEach(function() {
return this.ProjectInvite.find.callsArgWith(1, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, invites) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -264,7 +264,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should have called _sendMessages', function(done) {
it('should have called _sendMessages', function(done) {
return this.call((err, invite) => {
this.CollaboratorsInviteHandler._sendMessages.callCount.should.equal(
1
@@ -277,14 +277,14 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when saving model produces an error', function() {
describe('when saving model produces an error', function() {
beforeEach(function() {
return (this.ProjectInvite.prototype.save = sinon.spy(function(cb) {
return cb(new Error('woops'), this)
}))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, invite) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -332,7 +332,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should call _trySendInviteNotification', function(done) {
it('should call _trySendInviteNotification', function(done) {
return this.call(err => {
this.CollaboratorsInviteHandler._trySendInviteNotification.callCount.should.equal(
1
@@ -359,7 +359,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not call _trySendInviteNotification', function(done) {
it('should not call _trySendInviteNotification', function(done) {
return this.call(err => {
this.CollaboratorsInviteHandler._trySendInviteNotification.callCount.should.equal(
0
@@ -369,14 +369,14 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when _trySendInviteNotification produces an error', function() {
describe('when _trySendInviteNotification produces an error', function() {
beforeEach(function() {
return (this.CollaboratorsInviteHandler._trySendInviteNotification = sinon
.stub()
.callsArgWith(3, new Error('woops')))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, invite) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -421,7 +421,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should call _tryCancelInviteNotification', function(done) {
it('should call _tryCancelInviteNotification', function(done) {
return this.call(err => {
this.CollaboratorsInviteHandler._tryCancelInviteNotification.callCount.should.equal(
1
@@ -434,12 +434,12 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when remove produces an error', function() {
describe('when remove produces an error', function() {
beforeEach(function() {
return this.ProjectInvite.remove.callsArgWith(1, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.be.instanceof(Error)
return done()
@@ -485,7 +485,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should have called _sendMessages', function(done) {
it('should have called _sendMessages', function(done) {
return this.call((err, invite) => {
this.CollaboratorsInviteHandler._sendMessages.callCount.should.equal(
1
@@ -510,7 +510,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not have called _sendMessages', function(done) {
it('should not have called _sendMessages', function(done) {
return this.call((err, invite) => {
this.CollaboratorsInviteHandler._sendMessages.callCount.should.equal(
0
@@ -520,7 +520,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when findOne does not find an invite', function() {
describe('when findOne does not find an invite', function() {
beforeEach(function() {
return this.ProjectInvite.findOne.callsArgWith(1, null, null)
})
@@ -533,7 +533,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not have called _sendMessages', function(done) {
it('should not have called _sendMessages', function(done) {
return this.call((err, invite) => {
this.CollaboratorsInviteHandler._sendMessages.callCount.should.equal(
0
@@ -574,7 +574,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should call ProjectInvite.findOne', function(done) {
it('should call ProjectInvite.findOne', function(done) {
return this.call((err, invite) => {
this.ProjectInvite.findOne.callCount.should.equal(1)
this.ProjectInvite.findOne
@@ -590,7 +590,7 @@ describe('CollaboratorsInviteHandler', function() {
return this.ProjectInvite.findOne.callsArgWith(1, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, invite) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -598,7 +598,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when findOne does not find an invite', function() {
describe('when findOne does not find an invite', function() {
beforeEach(function() {
return this.ProjectInvite.findOne.callsArgWith(1, null, null)
})
@@ -611,7 +611,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not produce an invite object', function(done) {
it('should not produce an invite object', function(done) {
return this.call((err, invite) => {
expect(invite).to.not.be.instanceof(Error)
expect(invite).to.be.oneOf([null, undefined])
@@ -688,7 +688,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should have called ProjectInvite.remove', function(done) {
it('should have called ProjectInvite.remove', function(done) {
return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(1)
this.ProjectInvite.remove
@@ -713,7 +713,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should have called CollaboratorsHandler.addUserIdToProject', function(done) {
it('should have called CollaboratorsHandler.addUserIdToProject', function(done) {
return this.call(err => {
this.CollaboratorsHandler.addUserIdToProject.callCount.should.equal(1)
this.CollaboratorsHandler.addUserIdToProject
@@ -759,7 +759,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not have called ProjectInvite.remove', function(done) {
it('should not have called ProjectInvite.remove', function(done) {
return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(0)
return done()
@@ -796,7 +796,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not have called ProjectInvite.remove', function(done) {
it('should not have called ProjectInvite.remove', function(done) {
return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(0)
return done()
@@ -844,7 +844,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not have called ProjectInvite.remove', function(done) {
it('should not have called ProjectInvite.remove', function(done) {
return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(0)
return done()
@@ -852,7 +852,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when ProjectInvite.remove produces an error', function() {
describe('when ProjectInvite.remove produces an error', function() {
beforeEach(function() {
return this.ProjectInvite.remove.callsArgWith(1, new Error('woops'))
})
@@ -889,7 +889,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should have called ProjectInvite.remove', function(done) {
it('should have called ProjectInvite.remove', function(done) {
return this.call(err => {
this.ProjectInvite.remove.callCount.should.equal(1)
return done()
@@ -928,7 +928,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when notification.read produces an error', function() {
describe('when notification.read produces an error', function() {
beforeEach(function() {
this.notification = {
read: sinon.stub().callsArgWith(0, new Error('woops'))
@@ -938,7 +938,7 @@ describe('CollaboratorsInviteHandler', function() {
.returns(this.notification))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.be.instanceof(Error)
return done()
@@ -947,7 +947,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('_trySendInviteNotification', function() {
describe('_trySendInviteNotification', function() {
beforeEach(function() {
this.invite = {
_id: ObjectId(),
@@ -1039,7 +1039,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not call NotificationsBuilder.projectInvite.create', function(done) {
it('should not call NotificationsBuilder.projectInvite.create', function(done) {
return this.call(err => {
this.NotificationsBuilder.projectInvite.callCount.should.equal(0)
this.notification.create.callCount.should.equal(0)
@@ -1048,12 +1048,12 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when projectInvite.create produces an error', function() {
describe('when projectInvite.create produces an error', function() {
beforeEach(function() {
return this.notification.create.callsArgWith(0, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1093,7 +1093,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not call NotificationsBuilder.projectInvite.create', function(done) {
it('should not call NotificationsBuilder.projectInvite.create', function(done) {
return this.call(err => {
this.NotificationsBuilder.projectInvite.callCount.should.equal(0)
this.notification.create.callCount.should.equal(0)
@@ -1102,7 +1102,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return describe('when the getUser produces an error', function() {
describe('when the getUser produces an error', function() {
beforeEach(function() {
return (this.UserGetter.getUserByAnyEmail = sinon
.stub()
@@ -1133,7 +1133,7 @@ describe('CollaboratorsInviteHandler', function() {
})
})
return it('should not call NotificationsBuilder.projectInvite.create', function(done) {
it('should not call NotificationsBuilder.projectInvite.create', function(done) {
return this.call(err => {
this.NotificationsBuilder.projectInvite.callCount.should.equal(0)
this.notification.create.callCount.should.equal(0)
@@ -105,7 +105,7 @@ describe('ClsiCookieManager', function() {
)
})
return it('should _populateServerIdViaRequest if no key is blank', function(done) {
it('should _populateServerIdViaRequest if no key is blank', function(done) {
this.ClsiCookieManager._populateServerIdViaRequest = sinon
.stub()
.callsArgWith(1)
@@ -143,7 +143,7 @@ describe('ClsiCookieManager', function() {
)
})
return it('should return the server id', function(done) {
it('should return the server id', function(done) {
return this.ClsiCookieManager._populateServerIdViaRequest(
this.project_id,
(err, serverId) => {
@@ -222,7 +222,7 @@ describe('ClsiCookieManager', function() {
)
})
return it('should also set in the secondary if secondary redis is enabled', function(done) {
it('should also set in the secondary if secondary redis is enabled', function(done) {
this.redisSecondaryMulti = {
set: sinon.stub(),
expire: sinon.stub(),
@@ -260,7 +260,7 @@ describe('ClsiCookieManager', function() {
})
})
return describe('getCookieJar', function() {
describe('getCookieJar', function() {
beforeEach(function() {
return (this.ClsiCookieManager._getServerId = sinon
.stub()
@@ -282,7 +282,7 @@ describe('ClsiCookieManager', function() {
)
})
return it('should return empty cookie jar if clsiCookies are not enabled', function(done) {
it('should return empty cookie jar if clsiCookies are not enabled', function(done) {
delete this.settings.clsiCookie.key
this.ClsiCookieManager = SandboxedModule.require(modulePath, {
requires: this.requires
@@ -33,7 +33,7 @@ describe('ClsiFormatChecker', function() {
return (this.project_id = 'project-id')
})
return describe('checkRecoursesForProblems', function() {
describe('checkRecoursesForProblems', function() {
beforeEach(function() {
return (this.resources = [
{
@@ -175,7 +175,7 @@ describe('ClsiFormatChecker', function() {
)
})
return it('should not flag up when the file is a substring of a path', function(done) {
it('should not flag up when the file is a substring of a path', function(done) {
this.resources.push({
path: 'stuf',
content: 'other stuff'
@@ -191,7 +191,7 @@ describe('ClsiFormatChecker', function() {
})
})
return describe('_checkDocsAreUnderSizeLimit', function() {
describe('_checkDocsAreUnderSizeLimit', function() {
it('should error when there is more than 5mb of data', function(done) {
this.resources.push({
path: 'massive.tex',
@@ -219,7 +219,7 @@ describe('ClsiFormatChecker', function() {
)
})
return it('should return nothing when project is correct size', function(done) {
it('should return nothing when project is correct size', function(done) {
this.resources.push({
path: 'massive.tex',
content: require('crypto')
@@ -140,7 +140,7 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should call the callback with the status and output files', function() {
it('should call the callback with the status and output files', function() {
const outputFiles = [
{
url: `/project/${this.project_id}/user/${
@@ -180,7 +180,7 @@ describe('ClsiManager', function() {
)
})
return it('should call the callback with a failure status', function() {
it('should call the callback with a failure status', function() {
return this.callback.calledWith(null, this.status).should.equal(true)
})
})
@@ -218,12 +218,12 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should call the callback with a success status', function() {
it('should call the callback with a success status', function() {
return this.callback.calledWith(null, this.status).should.equal(true)
})
})
return describe('when the resources fail the precompile check', function() {
describe('when the resources fail the precompile check', function() {
beforeEach(function() {
this.ClsiFormatChecker.checkRecoursesForProblems = sinon
.stub()
@@ -245,7 +245,7 @@ describe('ClsiManager', function() {
return this.callback.calledOnce.should.equal(true)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback
.calledWithExactly(new Error('failed'))
.should.equal(true)
@@ -299,7 +299,7 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should call the callback with the status and output files', function() {
it('should call the callback with the status and output files', function() {
const outputFiles = [
{
url: `/project/${this.submission_id}/build/1234/output/output.pdf`,
@@ -335,12 +335,12 @@ describe('ClsiManager', function() {
)
})
return it('should call the callback with a failure status', function() {
it('should call the callback with a failure status', function() {
return this.callback.calledWith(null, this.status).should.equal(true)
})
})
return describe('when the resources fail the precompile check', function() {
describe('when the resources fail the precompile check', function() {
beforeEach(function() {
this.ClsiFormatChecker.checkRecoursesForProblems = sinon
.stub()
@@ -362,7 +362,7 @@ describe('ClsiManager', function() {
return this.callback.calledOnce.should.equal(true)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback
.calledWithExactly(new Error('failed'))
.should.equal(true)
@@ -378,7 +378,7 @@ describe('ClsiManager', function() {
.callsArg(1))
})
return describe('with the standard compileGroup', function() {
describe('with the standard compileGroup', function() {
beforeEach(function() {
return this.ClsiManager.deleteAuxFiles(
this.project_id,
@@ -405,7 +405,7 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -497,7 +497,7 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should build up the CLSI request', function() {
it('should build up the CLSI request', function() {
return expect(this.request).to.deep.equal({
compile: {
options: {
@@ -609,7 +609,7 @@ describe('ClsiManager', function() {
})
})
return describe('when the root doc is set and not in the docupdater', function() {
describe('when the root doc is set and not in the docupdater', function() {
beforeEach(function(done) {
this.ClsiStateManager.computeHash = sinon
.stub()
@@ -643,7 +643,7 @@ describe('ClsiManager', function() {
)
})
return it('should still change the root path', function() {
it('should still change the root path', function() {
return this.request.compile.rootResourcePath.should.equal(
'chapters/chapter1.tex'
)
@@ -663,7 +663,7 @@ describe('ClsiManager', function() {
)
})
return it('should change root path', function() {
it('should change root path', function() {
return this.request.compile.rootResourcePath.should.equal(
'chapters/chapter1.tex'
)
@@ -682,7 +682,7 @@ describe('ClsiManager', function() {
)
})
return it('should fallback to default root doc', function() {
it('should fallback to default root doc', function() {
return this.request.compile.rootResourcePath.should.equal('main.tex')
})
})
@@ -700,7 +700,7 @@ describe('ClsiManager', function() {
)
})
return it('should set the compiler to pdflatex', function() {
it('should set the compiler to pdflatex', function() {
return this.request.compile.options.compiler.should.equal('pdflatex')
})
})
@@ -719,7 +719,7 @@ describe('ClsiManager', function() {
)
})
return it('should set to main.tex', function() {
it('should set to main.tex', function() {
return this.request.compile.rootResourcePath.should.equal('main.tex')
})
})
@@ -745,7 +745,7 @@ describe('ClsiManager', function() {
return this.ClsiManager._buildRequest(this.project, null, this.callback)
})
return it('should report an error', function() {
it('should report an error', function() {
return this.callback
.calledWith(new Error('no main file specified'))
.should.equal(true)
@@ -776,12 +776,12 @@ describe('ClsiManager', function() {
)
})
return it('should set io to the only file', function() {
it('should set io to the only file', function() {
return this.request.compile.rootResourcePath.should.equal('other.tex')
})
})
return describe('with the draft option', () =>
describe('with the draft option', () =>
it('should add the draft option into the request', function(done) {
return this.ClsiManager._buildRequest(
this.project_id,
@@ -831,12 +831,12 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should call the callback with the body and no error', function() {
it('should call the callback with the body and no error', function() {
return this.callback.calledWith(null, this.body).should.equal(true)
})
})
return describe('when the CLSI returns an error', function() {
describe('when the CLSI returns an error', function() {
beforeEach(function() {
this.ClsiManager._makeRequest = sinon
.stub()
@@ -855,7 +855,7 @@ describe('ClsiManager', function() {
)
})
return it('should call the callback with the body and the error', function() {
it('should call the callback with the body and the error', function() {
return this.callback
.calledWith(
new Error('CLSI returned non-success code: 500'),
@@ -908,7 +908,7 @@ describe('ClsiManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -924,7 +924,7 @@ describe('ClsiManager', function() {
)
})
return it('should call wordCount with param file', function() {
it('should call wordCount with param file', function() {
return this.ClsiManager._makeRequest
.calledWith(this.project_id, {
method: 'GET',
@@ -937,7 +937,7 @@ describe('ClsiManager', function() {
})
})
return describe('with image', function() {
describe('with image', function() {
beforeEach(function() {
this.req.compile.options.imageName = this.image =
'example.com/mock/image'
@@ -950,7 +950,7 @@ describe('ClsiManager', function() {
)
})
return it('should call wordCount with file and image', function() {
it('should call wordCount with file and image', function() {
return this.ClsiManager._makeRequest
.calledWith(this.project_id, {
method: 'GET',
@@ -984,7 +984,7 @@ describe('ClsiManager', function() {
})
})
return it('should set the cookie again on response as it might have changed', function(done) {
it('should set the cookie again on response as it might have changed', function(done) {
return this.ClsiManager._makeRequest(this.project_id, this.opts, () => {
this.ClsiCookieManager.setServerId
.calledWith(this.project_id, this.response)
@@ -994,7 +994,7 @@ describe('ClsiManager', function() {
})
})
return describe('_makeGoogleCloudRequest', function() {
describe('_makeGoogleCloudRequest', function() {
beforeEach(function() {
this.settings.apis.clsi_new = { url: 'https://compiles.somewhere.test' }
this.response = { there: 'something' }
@@ -1018,7 +1018,7 @@ describe('ClsiManager', function() {
)
})
return it('should not make a request if there is not clsi_new url', function(done) {
it('should not make a request if there is not clsi_new url', function(done) {
this.settings.apis.clsi_new = undefined
return this.ClsiManager._makeNewBackendRequest(
this.project_id,
@@ -37,7 +37,7 @@ describe('ClsiStateManager', function() {
return (this.callback = sinon.stub())
})
return describe('computeHash', function() {
describe('computeHash', function() {
beforeEach(function(done) {
this.docs = [
{ path: '/main.tex', doc: { _id: 'doc-id-1' } },
@@ -75,7 +75,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a hash value', function() {
it('should call the callback with a hash value', function() {
return this.callback
.calledWith(null, '21b1ab73aa3892bec452baf8ffa0956179e1880f')
.should.equal(true)
@@ -96,7 +96,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with the same hash value', function() {
it('should call the callback with the same hash value', function() {
return this.callback.calledWith(null, this.hash0).should.equal(true)
})
})
@@ -114,7 +114,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -134,7 +134,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -154,7 +154,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -177,7 +177,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -197,7 +197,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -217,7 +217,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -237,7 +237,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -257,7 +257,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
@@ -277,14 +277,14 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with a different hash value', function() {
it('should call the callback with a different hash value', function() {
return this.callback
.neverCalledWith(null, this.hash0)
.should.equal(true)
})
})
return describe('when the isAutoCompile option is changed', function() {
describe('when the isAutoCompile option is changed', function() {
beforeEach(function() {
this.options.isAutoCompile = !this.options.isAutoCompile
return this.ClsiStateManager.computeHash(
@@ -294,7 +294,7 @@ describe('ClsiStateManager', function() {
)
})
return it('should call the callback with the same hash value', function() {
it('should call the callback with the same hash value', function() {
return this.callback.calledWith(null, this.hash0).should.equal(true)
})
})
@@ -122,7 +122,7 @@ describe('CompileController', function() {
.should.equal(true)
})
return it('should send a successful response reporting the status and files', function() {
it('should send a successful response reporting the status and files', function() {
this.res.statusCode.should.equal(200)
return this.res.body.should.equal(
JSON.stringify({
@@ -139,20 +139,20 @@ describe('CompileController', function() {
return this.CompileController.compile(this.req, this.res, this.next)
})
return it('should do the compile with the auto compile flag', function() {
it('should do the compile with the auto compile flag', function() {
return this.CompileManager.compile
.calledWith(this.project_id, this.user_id, { isAutoCompile: true })
.should.equal(true)
})
})
return describe('with the draft attribute', function() {
describe('with the draft attribute', function() {
beforeEach(function() {
this.req.body = { draft: true }
return this.CompileController.compile(this.req, this.res, this.next)
})
return it('should do the compile without the draft compile flag', function() {
it('should do the compile without the draft compile flag', function() {
return this.CompileManager.compile
.calledWith(this.project_id, this.user_id, {
isAutoCompile: false,
@@ -213,7 +213,7 @@ describe('CompileController', function() {
)
})
return it('should use the supplied values', function() {
it('should use the supplied values', function() {
return this.ClsiManager.sendExternalRequest
.calledWith(
this.submission_id,
@@ -224,7 +224,7 @@ describe('CompileController', function() {
})
})
return describe('with other supported options but not compileGroup and timeout', function() {
describe('with other supported options but not compileGroup and timeout', function() {
beforeEach(function() {
this.req.body = {
rootResourcePath: 'main.tex',
@@ -239,7 +239,7 @@ describe('CompileController', function() {
)
})
return it('should use the other options but default values for compileGroup and timeout', function() {
it('should use the other options but default values for compileGroup and timeout', function() {
return this.ClsiManager.sendExternalRequest
.calledWith(
this.submission_id,
@@ -303,7 +303,7 @@ describe('CompileController', function() {
return this.Metrics.inc.calledWith('pdf-downloads').should.equal(true)
})
return it('should proxy the PDF from the CLSI', function() {
it('should proxy the PDF from the CLSI', function() {
return this.CompileController.proxyToClsi
.calledWith(
this.project_id,
@@ -326,7 +326,7 @@ describe('CompileController', function() {
return this.CompileController.downloadPdf(this.req, this.res, this.next)
})
return it('should proxy the PDF from the CLSI, with a build-id', function() {
it('should proxy the PDF from the CLSI, with a build-id', function() {
return this.CompileController.proxyToClsi
.calledWith(
this.project_id,
@@ -341,7 +341,7 @@ describe('CompileController', function() {
})
})
return describe('when the pdf is not going to be used in pdfjs viewer', function() {
describe('when the pdf is not going to be used in pdfjs viewer', function() {
it('should check the rate limiter when pdfng is not set', function(done) {
this.req.query = {}
this.RateLimiter.addCount.callsArgWith(1, null, true)
@@ -352,7 +352,7 @@ describe('CompileController', function() {
return this.CompileController.downloadPdf(this.req, this.res)
})
return it('should check the rate limiter when pdfng is false', function(done) {
it('should check the rate limiter when pdfng is false', function(done) {
this.req.query = { pdfng: false }
this.RateLimiter.addCount.callsArgWith(1, null, true)
this.CompileController.proxyToClsi = (project_id, url) => {
@@ -390,7 +390,7 @@ describe('CompileController', function() {
)
})
return it('should proxy to CLSI with correct URL and default limits', function() {
it('should proxy to CLSI with correct URL and default limits', function() {
return this.CompileController.proxyToClsiWithLimits
.calledWith(this.submission_id, this.expected_url, {
compileGroup: 'standard'
@@ -399,7 +399,7 @@ describe('CompileController', function() {
})
})
return describe('with limits specified', function() {
describe('with limits specified', function() {
beforeEach(function() {
this.req.body = { compileTimeout: 600, compileGroup: 'special' }
return this.CompileController.getFileFromClsiWithoutUser(
@@ -409,7 +409,7 @@ describe('CompileController', function() {
)
})
return it('should proxy to CLSI with correct URL and specified limits', function() {
it('should proxy to CLSI with correct URL and specified limits', function() {
return this.CompileController.proxyToClsiWithLimits
.calledWith(this.submission_id, this.expected_url, {
compileGroup: 'special'
@@ -470,7 +470,7 @@ describe('CompileController', function() {
return this.proxy.pipe.calledWith(this.res).should.equal(true)
})
return it('should bind an error handle to the request proxy', function() {
it('should bind an error handle to the request proxy', function() {
return this.proxy.on.calledWith('error').should.equal(true)
})
})
@@ -516,7 +516,7 @@ describe('CompileController', function() {
return this.proxy.pipe.calledWith(this.res).should.equal(true)
})
return it('should bind an error handle to the request proxy', function() {
it('should bind an error handle to the request proxy', function() {
return this.proxy.on.calledWith('error').should.equal(true)
})
})
@@ -533,7 +533,7 @@ describe('CompileController', function() {
)
})
return it('should proxy to the standard url', function() {
it('should proxy to the standard url', function() {
return this.request
.calledWith({
jar: this.jar,
@@ -545,7 +545,7 @@ describe('CompileController', function() {
})
})
return describe('user with build parameter via query string', function() {
describe('user with build parameter via query string', function() {
beforeEach(function() {
this.CompileManager.getProjectCompileLimits = sinon
.stub()
@@ -560,7 +560,7 @@ describe('CompileController', function() {
)
})
return it('should proxy to the standard url without the build parameter', function() {
it('should proxy to the standard url without the build parameter', function() {
return this.request
.calledWith({
jar: this.jar,
@@ -573,7 +573,7 @@ describe('CompileController', function() {
})
})
return describe('new pdf viewer', function() {
describe('new pdf viewer', function() {
beforeEach(function() {
return (this.req.query = { pdfng: true })
})
@@ -611,12 +611,12 @@ describe('CompileController', function() {
return this.proxy.pipe.calledWith(this.res).should.equal(true)
})
return it('should bind an error handle to the request proxy', function() {
it('should bind an error handle to the request proxy', function() {
return this.proxy.on.calledWith('error').should.equal(true)
})
})
return describe('user with build parameter via query string', function() {
describe('user with build parameter via query string', function() {
beforeEach(function() {
this.CompileManager.getProjectCompileLimits = sinon
.stub()
@@ -631,7 +631,7 @@ describe('CompileController', function() {
)
})
return it('should proxy to the standard url with the build parameter', function() {
it('should proxy to the standard url with the build parameter', function() {
return this.request
.calledWith({
jar: this.jar,
@@ -669,7 +669,7 @@ describe('CompileController', function() {
.should.equal(true)
})
return it('should return a 200', function() {
it('should return a 200', function() {
return this.res.sendStatus.calledWith(200).should.equal(true)
})
})
@@ -692,7 +692,7 @@ describe('CompileController', function() {
return done()
})
return it('should proxy the res to the clsi with correct url', function(done) {
it('should proxy the res to the clsi with correct url', function(done) {
this.CompileController.compileAndDownloadPdf(this.req, this.res)
sinon.assert.calledWith(
this.CompileController.proxyToClsi,
@@ -714,7 +714,7 @@ describe('CompileController', function() {
})
})
return describe('wordCount', function() {
describe('wordCount', function() {
beforeEach(function() {
this.CompileManager.wordCount = sinon
.stub()
@@ -731,7 +731,7 @@ describe('CompileController', function() {
.should.equal(true)
})
return it('should return a 200 and body', function() {
it('should return a 200 and body', function() {
return this.res.send.calledWith({ content: 'body' }).should.equal(true)
})
})
@@ -140,7 +140,7 @@ describe('CompileManager', function() {
return this.Metrics.Timer.prototype.done.called.should.equal(true)
})
return it('should log out the compile', function() {
it('should log out the compile', function() {
return this.logger.log
.calledWith(
{ project_id: this.project_id, user_id: this.user_id },
@@ -171,7 +171,7 @@ describe('CompileManager', function() {
)
}))
return describe('should check the rate limit', () =>
describe('should check the rate limit', () =>
it('should return', function(done) {
this.CompileManager._checkIfAutoCompileLimitHasBeenHit = sinon
.stub()
@@ -222,7 +222,7 @@ describe('CompileManager', function() {
.should.equal(true)
})
return it('should return the limits', function() {
it('should return the limits', function() {
return this.callback
.calledWith(null, {
timeout: this.timeout,
@@ -261,7 +261,7 @@ describe('CompileManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -289,12 +289,12 @@ describe('CompileManager', function() {
.should.equal(true)
})
return it('should call the callback with true', function() {
it('should call the callback with true', function() {
return this.callback.calledWith(null, true).should.equal(true)
})
})
return describe('when the key does not exist in redis', function() {
describe('when the key does not exist in redis', function() {
beforeEach(function() {
this.rclient.set = sinon.stub().callsArgWith(5, null, 'OK')
return this.CompileManager._checkIfRecentlyCompiled(
@@ -316,7 +316,7 @@ describe('CompileManager', function() {
.should.equal(true)
})
return it('should call the callback with false', function() {
it('should call the callback with false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
@@ -364,7 +364,7 @@ describe('CompileManager', function() {
)
})
return it('should return false if there is an error in the rate limit', function(done) {
it('should return false if there is an error in the rate limit', function(done) {
this.ratelimiter.addCount.callsArgWith(1, 'error')
return this.CompileManager._checkIfAutoCompileLimitHasBeenHit(
true,
@@ -377,7 +377,7 @@ describe('CompileManager', function() {
})
})
return describe('wordCount', function() {
describe('wordCount', function() {
beforeEach(function() {
this.CompileManager.getProjectCompileLimits = sinon
.stub()
@@ -407,7 +407,7 @@ describe('CompileManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -44,7 +44,7 @@ describe('ContactController', function() {
return (this.res.send = sinon.stub())
})
return describe('getContacts', function() {
describe('getContacts', function() {
beforeEach(function() {
this.user_id = 'mock-user-id'
this.contact_ids = ['contact-1', 'contact-2', 'contact-3']
@@ -115,7 +115,7 @@ describe('ContactController', function() {
.should.equal(true)
})
return it('should return a formatted list of contacts in contact list order, without holding accounts', function() {
it('should return a formatted list of contacts in contact list order, without holding accounts', function() {
return this.res.send.args[0][0].contacts.should.deep.equal([
{
id: 'contact-1',
@@ -71,14 +71,14 @@ describe('ContactManager', function() {
.should.equal(true)
})
return it('should call the callback with the contatcs', function() {
it('should call the callback with the contatcs', function() {
return this.callback
.calledWith(null, this.contact_ids)
.should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.get = sinon
.stub()
@@ -98,7 +98,7 @@ describe('ContactManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -114,7 +114,7 @@ describe('ContactManager', function() {
})
})
return describe('addContact', function() {
describe('addContact', function() {
describe('with a successful response code', function() {
beforeEach(function() {
this.request.post = sinon
@@ -141,12 +141,12 @@ describe('ContactManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.post = sinon
.stub()
@@ -166,7 +166,7 @@ describe('ContactManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -66,7 +66,7 @@ describe('CooldownManager', function() {
})
})
return it('should produce a true result', function(done) {
it('should produce a true result', function(done) {
return this.call((err, result) => {
expect(result).to.equal(true)
return done()
@@ -94,7 +94,7 @@ describe('CooldownManager', function() {
})
})
return it('should produce a false result', function(done) {
it('should produce a false result', function(done) {
return this.call((err, result) => {
expect(result).to.equal(false)
return done()
@@ -102,7 +102,7 @@ describe('CooldownManager', function() {
})
})
return describe('when rclient.get produces an error', function() {
describe('when rclient.get produces an error', function() {
beforeEach(function() {
return (this.rclient.get = sinon
.stub()
@@ -117,7 +117,7 @@ describe('CooldownManager', function() {
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -127,7 +127,7 @@ describe('CooldownManager', function() {
})
})
return describe('putProjectOnCooldown', function() {
describe('putProjectOnCooldown', function() {
beforeEach(function() {
return (this.call = cb => {
return this.CooldownManager.putProjectOnCooldown(this.projectId, cb)
@@ -147,7 +147,7 @@ describe('CooldownManager', function() {
})
})
return it('should not produce an error', function(done) {
it('should not produce an error', function(done) {
return this.call(err => {
expect(err).to.equal(null)
return done()
@@ -155,7 +155,7 @@ describe('CooldownManager', function() {
})
})
return describe('when rclient.set produces an error', function() {
describe('when rclient.set produces an error', function() {
beforeEach(function() {
return (this.rclient.set = sinon
.stub()
@@ -170,7 +170,7 @@ describe('CooldownManager', function() {
})
})
return it('produce an error', function(done) {
it('produce an error', function(done) {
return this.call(err => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -29,7 +29,7 @@ describe('CooldownMiddleware', function() {
}))
})
return describe('freezeProject', function() {
describe('freezeProject', function() {
describe('when project is on cooldown', function() {
beforeEach(function() {
this.CooldownManager.isProjectOnCooldown = sinon
@@ -53,7 +53,7 @@ describe('CooldownMiddleware', function() {
return this.next.callCount.should.equal(0)
})
return it('should send a 429 status', function() {
it('should send a 429 status', function() {
this.CooldownMiddleware.freezeProject(this.req, this.res, this.next)
this.res.sendStatus.callCount.should.equal(1)
return this.res.sendStatus.calledWith(429).should.equal(true)
@@ -78,7 +78,7 @@ describe('CooldownMiddleware', function() {
.should.equal(true)
})
return it('call next with no arguments', function() {
it('call next with no arguments', function() {
this.CooldownMiddleware.freezeProject(this.req, this.res, this.next)
this.next.callCount.should.equal(1)
return expect(this.next.lastCall.args.length).to.equal(0)
@@ -103,14 +103,14 @@ describe('CooldownMiddleware', function() {
.should.equal(true)
})
return it('call next with an error', function() {
it('call next with an error', function() {
this.CooldownMiddleware.freezeProject(this.req, this.res, this.next)
this.next.callCount.should.equal(1)
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
})
})
return describe('when projectId is not part of route', function() {
describe('when projectId is not part of route', function() {
beforeEach(function() {
this.CooldownManager.isProjectOnCooldown = sinon
.stub()
@@ -126,7 +126,7 @@ describe('CooldownMiddleware', function() {
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
})
return it('should not call CooldownManager.isProjectOnCooldown', function() {
it('should not call CooldownManager.isProjectOnCooldown', function() {
this.CooldownMiddleware.freezeProject(this.req, this.res, this.next)
return this.CooldownManager.isProjectOnCooldown.callCount.should.equal(
0
@@ -69,7 +69,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should call the callback without an error', function() {
it('should call the callback without an error', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -94,7 +94,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -110,7 +110,7 @@ describe('DocstoreManager', function() {
})
})
return describe('with a missing (404) response code', function() {
describe('with a missing (404) response code', function() {
beforeEach(function() {
this.request.del = sinon
.stub()
@@ -130,7 +130,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -191,14 +191,14 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should call the callback with the modified status and revision', function() {
it('should call the callback with the modified status and revision', function() {
return this.callback
.calledWith(null, this.modified, this.rev)
.should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.post = sinon
.stub()
@@ -221,7 +221,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -271,7 +271,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should call the callback with the lines, version and rev', function() {
it('should call the callback with the lines, version and rev', function() {
return this.callback
.calledWith(null, this.lines, this.rev, this.version, this.ranges)
.should.equal(true)
@@ -298,7 +298,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -338,14 +338,14 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should call the callback with the lines, version and rev', function() {
it('should call the callback with the lines, version and rev', function() {
return this.callback
.calledWith(null, this.lines, this.rev, this.version, this.ranges)
.should.equal(true)
})
})
return describe('with a missing (404) response code', function() {
describe('with a missing (404) response code', function() {
beforeEach(function() {
this.request.get = sinon
.stub()
@@ -363,7 +363,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -403,12 +403,12 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should call the callback with the docs', function() {
it('should call the callback with the docs', function() {
return this.callback.calledWith(null, this.docs).should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.get = sinon
.stub()
@@ -424,7 +424,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -465,12 +465,12 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should call the callback with the docs', function() {
it('should call the callback with the docs', function() {
return this.callback.calledWith(null, this.docs).should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.get = sinon
.stub()
@@ -486,7 +486,7 @@ describe('DocstoreManager', function() {
.should.equal(true)
})
return it('should log the error', function() {
it('should log the error', function() {
return this.logger.error
.calledWith(
{
@@ -514,12 +514,12 @@ describe('DocstoreManager', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.post = sinon
.stub()
@@ -530,7 +530,7 @@ describe('DocstoreManager', function() {
)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback
.calledWith(
new Error('docstore api responded with non-success code: 500')
@@ -540,7 +540,7 @@ describe('DocstoreManager', function() {
})
})
return describe('unarchiveProject', function() {
describe('unarchiveProject', function() {
describe('with a successful response code', function() {
beforeEach(function() {
this.request.post = sinon
@@ -552,12 +552,12 @@ describe('DocstoreManager', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('with a failed response code', function() {
describe('with a failed response code', function() {
beforeEach(function() {
this.request.post = sinon
.stub()
@@ -568,7 +568,7 @@ describe('DocstoreManager', function() {
)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback
.calledWith(
new Error('docstore api responded with non-success code: 500')
@@ -89,7 +89,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback with no error', function() {
it('should call the callback with no error', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -105,18 +105,18 @@ describe('DocumentUpdaterHandler', function() {
return this.handler.flushProjectToMongo(this.project_id, this.callback)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.flushProjectToMongo(this.project_id, this.callback)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -147,7 +147,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback with no error', function() {
it('should call the callback with no error', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -166,12 +166,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.flushProjectToMongoAndDelete(
@@ -180,7 +180,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -212,7 +212,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback with no error', function() {
it('should call the callback with no error', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -232,12 +232,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.flushDocToMongo(
@@ -247,7 +247,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -279,7 +279,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback with no error', function() {
it('should call the callback with no error', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -299,12 +299,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.deleteDoc(
@@ -314,7 +314,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -358,7 +358,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback with no error', function() {
it('should call the callback with no error', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -381,12 +381,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.setDocument(
@@ -399,7 +399,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -440,7 +440,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback with the lines and version', function() {
it('should call the callback with the lines and version', function() {
return this.callback
.calledWith(null, this.lines, this.version, this.ranges, this.ops)
.should.equal(true)
@@ -463,12 +463,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.getDocument(
@@ -479,7 +479,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -520,7 +520,7 @@ describe('DocumentUpdaterHandler', function() {
return this.request.post.calledWith(url).should.equal(true)
})
return it('should call the callback with the documents', function() {
it('should call the callback with the documents', function() {
return this.callback
.calledWithExactly(null, this.docs)
.should.equal(true)
@@ -544,12 +544,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a conflict error code', function() {
describe('when the document updater returns a conflict error code', function() {
beforeEach(function() {
this.request.post = sinon
.stub()
@@ -561,7 +561,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with no documents', function() {
it('should return the callback with no documents', function() {
return this.callback.alwaysCalledWithExactly().should.equal(true)
})
})
@@ -585,7 +585,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -601,18 +601,18 @@ describe('DocumentUpdaterHandler', function() {
return this.handler.clearProjectState(this.project_id, this.callback)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns an error code', function() {
describe('when the document updater returns an error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, null)
return this.handler.clearProjectState(this.project_id, this.callback)
})
return it('should return the callback with no documents', function() {
it('should return the callback with no documents', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -652,7 +652,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -673,12 +673,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.acceptChanges(
@@ -689,7 +689,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -726,7 +726,7 @@ describe('DocumentUpdaterHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.calledWith(null).should.equal(true)
})
})
@@ -747,12 +747,12 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return an error to the callback', function() {
it('should return an error to the callback', function() {
return this.callback.calledWith(this.error).should.equal(true)
})
})
return describe('when the document updater returns a failure error code', function() {
describe('when the document updater returns a failure error code', function() {
beforeEach(function() {
this.request.callsArgWith(1, null, { statusCode: 500 }, '')
return this.handler.deleteThread(
@@ -763,7 +763,7 @@ describe('DocumentUpdaterHandler', function() {
)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
new Error('doc updater returned failure status code: 500')
@@ -773,7 +773,7 @@ describe('DocumentUpdaterHandler', function() {
})
})
return describe('updateProjectStructure ', function() {
describe('updateProjectStructure ', function() {
beforeEach(function() {
this.user_id = 1234
return (this.version = 999)
@@ -795,12 +795,12 @@ describe('DocumentUpdaterHandler', function() {
return this.request.called.should.equal(false)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('with project history enabled', function() {
describe('with project history enabled', function() {
beforeEach(function() {
this.settings.apis.project_history.sendProjectStructureOps = true
this.url = `${this.settings.apis.documentupdater.url}/project/${
@@ -998,7 +998,7 @@ describe('DocumentUpdaterHandler', function() {
)
}))
return describe('when the project version is missing', () =>
describe('when the project version is missing', () =>
it('should call the callback with an error', function() {
this.docId = new ObjectId()
this.changes = {
@@ -111,7 +111,7 @@ describe('DocumentController', function() {
.should.equal(true)
})
return it('should return the document data to the client as JSON', function() {
it('should return the document data to the client as JSON', function() {
this.res.type.should.equal('application/json')
return this.res.body.should.equal(
JSON.stringify({
@@ -124,7 +124,7 @@ describe('DocumentController', function() {
})
})
return describe("when the document doesn't exist", function() {
describe("when the document doesn't exist", function() {
beforeEach(function() {
this.ProjectLocator.findElement = sinon
.stub()
@@ -136,7 +136,7 @@ describe('DocumentController', function() {
)
})
return it('should call next with the NotFoundError', function() {
it('should call next with the NotFoundError', function() {
return this.next
.calledWith(new Errors.NotFoundError('not found'))
.should.equal(true)
@@ -175,7 +175,7 @@ describe('DocumentController', function() {
)
})
return it('should return the history id to the client as JSON', function() {
it('should return the history id to the client as JSON', function() {
this.res.type.should.equal('application/json')
return this.res.body.should.equal(
JSON.stringify({
@@ -189,7 +189,7 @@ describe('DocumentController', function() {
})
})
return describe('when the project does not exist', function() {
describe('when the project does not exist', function() {
beforeEach(function() {
this.ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, null)
return this.DocumentController.getDocument(
@@ -199,13 +199,13 @@ describe('DocumentController', function() {
)
})
return it('returns a 404', function() {
it('returns a 404', function() {
return this.res.statusCode.should.equal(404)
})
})
})
return describe('setDocument', function() {
describe('setDocument', function() {
beforeEach(function() {
return (this.req.params = {
Project_id: this.project_id,
@@ -243,12 +243,12 @@ describe('DocumentController', function() {
)
})
return it('should return a successful response', function() {
it('should return a successful response', function() {
return this.res.success.should.equal(true)
})
})
return describe("when the document doesn't exist", function() {
describe("when the document doesn't exist", function() {
beforeEach(function() {
this.ProjectEntityUpdateHandler.updateDocLines = sinon
.stub()
@@ -261,7 +261,7 @@ describe('DocumentController', function() {
)
})
return it('should call next with the NotFoundError', function() {
it('should call next with the NotFoundError', function() {
return this.next
.calledWith(new Errors.NotFoundError('not found'))
.should.equal(true)
@@ -78,7 +78,7 @@ describe('DocumentHelper', function() {
// document = "\\title{Second Year \\large{LaTeX} Exercise}"
// expect(@DocumentHelper.getTitleFromTexContent(document)).to.equal "Second Year LaTeX Exercise"
return it('should collapse whitespace', function() {
it('should collapse whitespace', function() {
const document = '\\title{Second Year LaTeX Exercise}'
return expect(
this.DocumentHelper.getTitleFromTexContent(document)
@@ -120,14 +120,14 @@ describe('DocumentHelper', function() {
)
})
return it('removes line spacing commands', function() {
it('removes line spacing commands', function() {
return expect(this.DocumentHelper.detex('a \\\\[1.50cm] b')).to.equal(
'a b'
)
})
})
return describe('contentHasDocumentclass', function() {
describe('contentHasDocumentclass', function() {
it('should return true if the content has a documentclass', function() {
const document = ['% line', '% line', '% line', '\\documentclass']
return expect(
@@ -154,7 +154,7 @@ describe('DocumentHelper', function() {
).to.equal(false)
})
return it('should return false when there is no documentclass', function() {
it('should return false when there is no documentclass', function() {
const document = ['% line', '% line', '% line']
return expect(
this.DocumentHelper.contentHasDocumentclass(document)
@@ -104,14 +104,14 @@ describe('ProjectDownloadsController', function() {
return this.metrics.inc.calledWith('zip-downloads').should.equal(true)
})
return it('should log the action', function() {
it('should log the action', function() {
return this.logger.log
.calledWith(sinon.match.any, 'downloading project')
.should.equal(true)
})
})
return describe('downloadMultipleProjects', function() {
describe('downloadMultipleProjects', function() {
beforeEach(function() {
this.stream = { pipe: sinon.stub() }
this.ProjectZipStreamManager.createZipStreamForMultipleProjects = sinon
@@ -168,7 +168,7 @@ describe('ProjectDownloadsController', function() {
.should.equal(true)
})
return it('should log the action', function() {
it('should log the action', function() {
return this.logger.log
.calledWith(sinon.match.any, 'downloading multiple projects')
.should.equal(true)
@@ -116,7 +116,7 @@ describe('ProjectZipStreamManager', function() {
)
})
return it('should add all of the projects to the zip', function() {
it('should add all of the projects to the zip', function() {
return Array.from(this.project_ids).map(project_id =>
this.archive.append
.calledWith(this.zip_streams[project_id], {
@@ -171,7 +171,7 @@ describe('ProjectZipStreamManager', function() {
.should.equal(true)
})
return it('should finalise the stream', function() {
it('should finalise the stream', function() {
return this.archive.finalize.called.should.equal(true)
})
})
@@ -197,7 +197,7 @@ describe('ProjectZipStreamManager', function() {
.should.equal(true)
})
return it('should continue with the process', function() {
it('should continue with the process', function() {
this.ProjectZipStreamManager.addAllDocsToArchive.called.should.equal(
true
)
@@ -208,7 +208,7 @@ describe('ProjectZipStreamManager', function() {
})
})
return describe('with an error adding files', function() {
describe('with an error adding files', function() {
beforeEach(function() {
this.ProjectZipStreamManager.addAllDocsToArchive = sinon
.stub()
@@ -229,7 +229,7 @@ describe('ProjectZipStreamManager', function() {
.should.equal(true)
})
return it('should continue with the process', function() {
it('should continue with the process', function() {
this.ProjectZipStreamManager.addAllDocsToArchive.called.should.equal(
true
)
@@ -275,7 +275,7 @@ describe('ProjectZipStreamManager', function() {
.should.equal(true)
})
return it('should add each doc to the archive', function() {
it('should add each doc to the archive', function() {
return (() => {
const result = []
for (let path in this.docs) {
@@ -292,7 +292,7 @@ describe('ProjectZipStreamManager', function() {
})
})
return describe('addAllFilesToArchive', function() {
describe('addAllFilesToArchive', function() {
beforeEach(function() {
this.files = {
'/image.png': {
@@ -351,7 +351,7 @@ describe('ProjectZipStreamManager', function() {
})()
})
return it('should add each file to the archive', function() {
it('should add each file to the archive', function() {
return (() => {
const result = []
for (let path in this.files) {
@@ -114,7 +114,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback.calledWith(null, this.doc).should.equal(true)
})
})
@@ -162,7 +162,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback.calledWith(null, this.file).should.equal(true)
})
})
@@ -199,7 +199,7 @@ describe('EditorController', function() {
return this.callback.calledWith(null, this.doc).should.equal(true)
})
return describe('doc does not exist', function() {
describe('doc does not exist', function() {
beforeEach(function() {
this.ProjectEntityUpdateHandler.upsertDoc = sinon
.stub()
@@ -215,7 +215,7 @@ describe('EditorController', function() {
)
})
return it('sends an update out to users in the project', function() {
it('sends an update out to users in the project', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -263,7 +263,7 @@ describe('EditorController', function() {
return this.callback.calledWith(null, this.newFile).should.equal(true)
})
return describe('file does not exist', function() {
describe('file does not exist', function() {
beforeEach(function() {
this.ProjectEntityUpdateHandler.upsertFile = sinon
.stub()
@@ -280,7 +280,7 @@ describe('EditorController', function() {
)
})
return it('should send the update out to users in the project', function() {
it('should send the update out to users in the project', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -333,7 +333,7 @@ describe('EditorController', function() {
)
})
return it('should send the update for the doc out to users in the project', function() {
it('should send the update for the doc out to users in the project', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -346,7 +346,7 @@ describe('EditorController', function() {
})
})
return describe('folders required for doc do not exist', function() {
describe('folders required for doc do not exist', function() {
beforeEach(function() {
const folders = [
(this.folderA = { _id: 2, parentFolder_id: 1 }),
@@ -365,7 +365,7 @@ describe('EditorController', function() {
)
})
return it('should send the update for each folder to users in the project', function() {
it('should send the update for each folder to users in the project', function() {
this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -431,7 +431,7 @@ describe('EditorController', function() {
)
})
return it('should send the update for the file out to users in the project', function() {
it('should send the update for the file out to users in the project', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -445,7 +445,7 @@ describe('EditorController', function() {
})
})
return describe('folders required for file do not exist', function() {
describe('folders required for file do not exist', function() {
beforeEach(function() {
const folders = [
(this.folderA = { _id: 2, parentFolder_id: 1 }),
@@ -465,7 +465,7 @@ describe('EditorController', function() {
)
})
return it('should send the update for each folder to users in the project', function() {
it('should send the update for each folder to users in the project', function() {
this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -517,7 +517,7 @@ describe('EditorController', function() {
)
})
return it('should return the folder in the callback', function() {
it('should return the folder in the callback', function() {
return this.callback.calledWith(null, this.folder).should.equal(true)
})
})
@@ -555,7 +555,7 @@ describe('EditorController', function() {
)
})
return it('should return the folder in the callback', function() {
it('should return the folder in the callback', function() {
return this.callback
.calledWith(null, this.folders, this.folder)
.should.equal(true)
@@ -586,7 +586,7 @@ describe('EditorController', function() {
).should.equal.true
})
return it('notify users an entity has been deleted', function() {
it('notify users an entity has been deleted', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -622,7 +622,7 @@ describe('EditorController', function() {
).should.equal.true
})
return it('notify users an entity has been deleted', function() {
it('notify users an entity has been deleted', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -666,7 +666,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('should notify the other clients about the updated description', function() {
it('should notify the other clients about the updated description', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -685,7 +685,7 @@ describe('EditorController', function() {
.callsArgWith(1, this.err))
})
return it('should call the project handler', function(done) {
it('should call the project handler', function(done) {
return this.EditorController.deleteProject(this.project_id, err => {
err.should.equal(this.err)
this.ProjectDeleter.deleteProject
@@ -725,7 +725,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('should emit the update to the room', function() {
it('should emit the update to the room', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(
this.project_id,
@@ -775,7 +775,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -797,7 +797,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('should emit the update to the room', function() {
it('should emit the update to the room', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'projectNameUpdated', this.newName)
.should.equal(true)
@@ -814,7 +814,7 @@ describe('EditorController', function() {
)
})
return it('should send the new compiler and project id to the project options handler', function() {
it('should send the new compiler and project id to the project options handler', function() {
this.ProjectOptionsHandler.setCompiler
.calledWith(this.project_id, this.compiler)
.should.equal(true)
@@ -834,7 +834,7 @@ describe('EditorController', function() {
)
})
return it('should send the new imageName and project id to the project options handler', function() {
it('should send the new imageName and project id to the project options handler', function() {
this.ProjectOptionsHandler.setImageName
.calledWith(this.project_id, this.imageName)
.should.equal(true)
@@ -854,7 +854,7 @@ describe('EditorController', function() {
)
})
return it('should send the new languageCode and project id to the project options handler', function() {
it('should send the new languageCode and project id to the project options handler', function() {
this.ProjectOptionsHandler.setSpellCheckLanguage
.calledWith(this.project_id, this.languageCode)
.should.equal(true)
@@ -900,7 +900,7 @@ describe('EditorController', function() {
.should.equal(false)
})
return it('should not broadcast a token change', function() {
it('should not broadcast a token change', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:tokens:changed', {
tokens: this.tokens
@@ -909,7 +909,7 @@ describe('EditorController', function() {
})
})
return describe('when setting to tokenBased', function() {
describe('when setting to tokenBased', function() {
beforeEach(function() {
this.newAccessLevel = 'tokenBased'
this.tokens = { readOnly: 'aaa', readAndWrite: '42bbb' }
@@ -941,7 +941,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('should broadcast the token change too', function() {
it('should broadcast the token change too', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'project:tokens:changed', {
tokens: this.tokens
@@ -951,7 +951,7 @@ describe('EditorController', function() {
})
})
return describe('setRootDoc', function() {
describe('setRootDoc', function() {
beforeEach(function() {
this.newRootDocID = '21312321321'
this.ProjectEntityUpdateHandler.setRootDoc = sinon.stub().yields()
@@ -968,7 +968,7 @@ describe('EditorController', function() {
.should.equal(true)
})
return it('should emit the update to the room', function() {
it('should emit the update to the room', function() {
return this.EditorRealTimeController.emitToRoom
.calledWith(this.project_id, 'rootDocUpdated', this.newRootDocID)
.should.equal(true)
@@ -101,7 +101,7 @@ describe('EditorHttpController', function() {
)
})
return it('should send an inc metric', function() {
it('should send an inc metric', function() {
return this.Metrics.inc
.calledWith('editor.join-project')
.should.equal(true)
@@ -114,20 +114,20 @@ describe('EditorHttpController', function() {
return this.EditorHttpController.joinProject(this.req, this.res)
})
return it('should unmark the project as deleted', function() {
it('should unmark the project as deleted', function() {
return this.ProjectDeleter.unmarkAsDeletedByExternalSource
.calledWith(this.project_id)
.should.equal(true)
})
})
return describe('with an anonymous user', function() {
describe('with an anonymous user', function() {
beforeEach(function() {
this.req.query = { user_id: 'anonymous-user' }
return this.EditorHttpController.joinProject(this.req, this.res)
})
return it('should pass the user id as null', function() {
it('should pass the user id as null', function() {
return this.EditorHttpController._buildJoinProjectView
.calledWith(this.req, this.project_id, null)
.should.equal(true)
@@ -223,14 +223,14 @@ describe('EditorHttpController', function() {
.should.equal(true)
})
return it('should return the project model view, privilege level and protocol version', function() {
it('should return the project model view, privilege level and protocol version', function() {
return this.callback
.calledWith(null, this.projectModelView, 'owner')
.should.equal(true)
})
})
return describe('when not authorized', function() {
describe('when not authorized', function() {
beforeEach(function() {
this.AuthorizationManager.getPrivilegeLevelForProject = sinon
.stub()
@@ -243,7 +243,7 @@ describe('EditorHttpController', function() {
)
})
return it('should return false in the callback', function() {
it('should return false in the callback', function() {
return this.callback.calledWith(null, null, false).should.equal(true)
})
})
@@ -280,18 +280,18 @@ describe('EditorHttpController', function() {
.should.equal(true)
})
return it('should send the doc back as JSON', function() {
it('should send the doc back as JSON', function() {
return this.res.json.calledWith(this.doc).should.equal(true)
})
})
return describe('unsuccesfully', function() {
describe('unsuccesfully', function() {
beforeEach(function() {
this.req.body.name = ''
return this.EditorHttpController.addDoc(this.req, this.res)
})
return it('should send back a bad request status code', function() {
it('should send back a bad request status code', function() {
return this.res.sendStatus.calledWith(400).should.equal(true)
})
})
@@ -326,18 +326,18 @@ describe('EditorHttpController', function() {
.should.equal(true)
})
return it('should send the folder back as JSON', function() {
it('should send the folder back as JSON', function() {
return this.res.json.calledWith(this.folder).should.equal(true)
})
})
return describe('unsuccesfully', function() {
describe('unsuccesfully', function() {
beforeEach(function() {
this.req.body.name = ''
return this.EditorHttpController.addFolder(this.req, this.res)
})
return it('should send back a bad request status code', function() {
it('should send back a bad request status code', function() {
return this.res.sendStatus.calledWith(400).should.equal(true)
})
})
@@ -367,7 +367,7 @@ describe('EditorHttpController', function() {
.should.equal(true)
})
return it('should send back a success response', function() {
it('should send back a success response', function() {
return this.res.sendStatus.calledWith(204).should.equal(true)
})
})
@@ -387,7 +387,7 @@ describe('EditorHttpController', function() {
return this.EditorHttpController.renameEntity(this.req, this.res)
})
return it('should send back a bad request status code', function() {
it('should send back a bad request status code', function() {
return this.res.sendStatus.calledWith(400).should.equal(true)
})
})
@@ -404,7 +404,7 @@ describe('EditorHttpController', function() {
return this.EditorHttpController.renameEntity(this.req, this.res)
})
return it('should send back a bad request status code', function() {
it('should send back a bad request status code', function() {
return this.res.sendStatus.calledWith(400).should.equal(true)
})
})
@@ -433,12 +433,12 @@ describe('EditorHttpController', function() {
.should.equal(true)
})
return it('should send back a success response', function() {
it('should send back a success response', function() {
return this.res.sendStatus.calledWith(204).should.equal(true)
})
})
return describe('deleteEntity', function() {
describe('deleteEntity', function() {
beforeEach(function() {
this.req.params = {
Project_id: this.project_id,
@@ -461,7 +461,7 @@ describe('EditorHttpController', function() {
.should.equal(true)
})
return it('should send back a success response', function() {
it('should send back a success response', function() {
return this.res.sendStatus.calledWith(204).should.equal(true)
})
})
@@ -55,7 +55,7 @@ describe('EditorRealTimeController', function() {
)
})
return it('should publish the message to redis', function() {
it('should publish the message to redis', function() {
return this.rclient.publish
.calledWith(
'editor-events',
@@ -70,7 +70,7 @@ describe('EditorRealTimeController', function() {
})
})
return describe('emitToAll', function() {
describe('emitToAll', function() {
beforeEach(function() {
this.EditorRealTimeController.emitToRoom = sinon.stub()
return this.EditorRealTimeController.emitToAll(
@@ -79,7 +79,7 @@ describe('EditorRealTimeController', function() {
)
})
return it("should emit to the room 'all'", function() {
it("should emit to the room 'all'", function() {
return this.EditorRealTimeController.emitToRoom
.calledWith('all', this.message, ...Array.from(this.payload))
.should.equal(true)
@@ -69,13 +69,13 @@ describe('EmailBuilder', function() {
return expect(this.email.text != null).to.equal(true)
})
return it('should not have undefined in it', function() {
it('should not have undefined in it', function() {
this.email.html.indexOf('undefined').should.equal(-1)
return this.email.subject.indexOf('undefined').should.equal(-1)
})
})
return describe('when someone is up to no good', function() {
describe('when someone is up to no good', function() {
beforeEach(function() {
this.opts.project.name = "<img src='http://evilsite.com/evil.php'>"
return (this.email = this.EmailBuilder.buildEmail(
@@ -88,14 +88,14 @@ describe('EmailBuilder', function() {
return expect(this.email.html).to.contain('New Project')
})
return it('should not have undefined in it', function() {
it('should not have undefined in it', function() {
this.email.html.indexOf('undefined').should.equal(-1)
return this.email.subject.indexOf('undefined').should.equal(-1)
})
})
})
return describe('SpamSafe', function() {
describe('SpamSafe', function() {
beforeEach(function() {
this.opts = {
to: 'bob@joe.com',
@@ -115,7 +115,7 @@ describe('EmailBuilder', function() {
))
})
return it('should replace spammy project name', function() {
it('should replace spammy project name', function() {
this.email.html.indexOf('a new project').should.not.equal(-1)
return this.email.subject.indexOf('New Project').should.not.equal(-1)
})
@@ -40,7 +40,7 @@ describe('EmailHandler', function() {
return (this.html = '<html>hello</html>')
})
return describe('send email', function() {
describe('send email', function() {
it('should use the correct options', function(done) {
this.EmailBuilder.buildEmail.returns({ html: this.html })
this.EmailSender.sendEmail.callsArgWith(1)
@@ -98,12 +98,12 @@ describe('EmailHandler', function() {
})
})
return describe('with plain-text email content', function() {
describe('with plain-text email content', function() {
beforeEach(function() {
return (this.text = 'hello there')
})
return it('should pass along the text field', function(done) {
it('should pass along the text field', function(done) {
this.EmailBuilder.buildEmail.returns({
html: this.html,
text: this.text
@@ -66,7 +66,7 @@ describe('EmailSender', function() {
})
})
return describe('sendEmail', function() {
describe('sendEmail', function() {
it('should set the properties on the email to send', function(done) {
this.sesClient.sendMail.callsArgWith(1)
@@ -148,12 +148,12 @@ describe('EmailSender', function() {
})
})
return describe('with plain-text email content', function() {
describe('with plain-text email content', function() {
beforeEach(function() {
return (this.opts.text = 'hello there')
})
return it('should set the text property on the email to send', function(done) {
it('should set the text property on the email to send', function(done) {
this.sesClient.sendMail.callsArgWith(1)
return this.sender.sendEmail(this.opts, () => {
@@ -106,7 +106,7 @@ describe('ExportsController', function() {
return (this.req.body.showSource = true)
})
return it('should ask the handler to perform the export', function(done) {
it('should ask the handler to perform the export', function(done) {
this.handler.exportProject = sinon
.stub()
.yields(null, { iAmAnExport: true, v1_id: 897 })
@@ -144,7 +144,7 @@ describe('ExportsController', function() {
return done()
}))
return it('should ask the handler to return the status of an export', function(done) {
it('should ask the handler to return the status of an export', function(done) {
this.handler.fetchExport = sinon.stub().yields(
null,
`{ \
@@ -98,7 +98,7 @@ describe('ExportsHandler', function() {
.should.equal(true)
})
return it('should return the export', function() {
it('should return the export', function() {
return this.callback
.calledWith(null, this.export_data)
.should.equal(true)
@@ -119,12 +119,12 @@ describe('ExportsHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
return describe('when export request returns an error to forward to the user', function() {
describe('when export request returns an error to forward to the user', function() {
beforeEach(function(done) {
this.error_json = { status: 422, message: 'nope' }
this.ExportsHandler._requestExport = sinon
@@ -139,7 +139,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return success and the response to forward', function() {
it('should return success and the response to forward', function() {
;(this.callback.args[0][0] instanceof Error).should.equal(false)
return this.callback.calledWith(null, {
forwardResponse: this.error_json
@@ -211,7 +211,7 @@ describe('ExportsHandler', function() {
return this.ExportsHandler._requestVersion.called.should.equal(true)
})
return it('should return export data', function() {
it('should return export data', function() {
const expected_export_data = {
project: {
id: this.project_id,
@@ -265,7 +265,7 @@ describe('ExportsHandler', function() {
)
})
return it('should send the data from the user input', function() {
it('should send the data from the user input', function() {
const expected_export_data = {
project: {
id: this.project_id,
@@ -318,7 +318,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
@@ -345,7 +345,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return export data', function() {
it('should return export data', function() {
const expected_export_data = {
project: {
id: this.project_id,
@@ -407,7 +407,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return export data', function() {
it('should return export data', function() {
const expected_export_data = {
project: {
id: this.project_id,
@@ -446,7 +446,7 @@ describe('ExportsHandler', function() {
})
})
return describe('when no root doc can be identified', function() {
describe('when no root doc can be identified', function() {
beforeEach(function(done) {
this.ProjectLocator.findRootDoc = sinon
.stub()
@@ -460,7 +460,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
@@ -480,12 +480,12 @@ describe('ExportsHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
return describe('when project history request fails', function() {
describe('when project history request fails', function() {
beforeEach(function(done) {
this.ExportsHandler._requestVersion = sinon
.stub()
@@ -499,7 +499,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
@@ -545,7 +545,7 @@ describe('ExportsHandler', function() {
})
})
return it('should return the v1 export id', function() {
it('should return the v1 export id', function() {
return this.callback.calledWith(null, this.export_id).should.equal(true)
})
})
@@ -564,12 +564,12 @@ describe('ExportsHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return (this.callback.args[0][0] instanceof Error).should.equal(true)
})
})
return describe('when the request returns an error response to forward', function() {
describe('when the request returns an error response to forward', function() {
beforeEach(function(done) {
this.error_code = 422
this.error_json = { status: this.error_code, message: 'nope' }
@@ -585,7 +585,7 @@ describe('ExportsHandler', function() {
)
})
return it('should return success and the response to forward', function() {
it('should return success and the response to forward', function() {
;(this.callback.args[0][0] instanceof Error).should.equal(false)
return this.callback.calledWith(null, {
forwardResponse: this.error_json
@@ -611,7 +611,7 @@ describe('ExportsHandler', function() {
return done()
})
return describe('when all goes well', function() {
describe('when all goes well', function() {
beforeEach(function(done) {
this.stubRequest.get = this.stubGet
return this.ExportsHandler.fetchExport(
@@ -636,7 +636,7 @@ describe('ExportsHandler', function() {
})
})
return it('should return the v1 export id', function() {
it('should return the v1 export id', function() {
return this.callback
.calledWith(null, { body: this.body })
.should.equal(true)
@@ -644,7 +644,7 @@ describe('ExportsHandler', function() {
})
})
return describe('fetchDownload', function() {
describe('fetchDownload', function() {
beforeEach(function(done) {
this.settings.apis = {
v1: {
@@ -662,7 +662,7 @@ describe('ExportsHandler', function() {
return done()
})
return describe('when all goes well', function() {
describe('when all goes well', function() {
beforeEach(function(done) {
this.stubRequest.get = this.stubGet
return this.ExportsHandler.fetchDownload(
@@ -689,7 +689,7 @@ describe('ExportsHandler', function() {
})
})
return it('should return the v1 export id', function() {
it('should return the v1 export id', function() {
return this.callback
.calledWith(null, { body: this.body })
.should.equal(true)
@@ -74,12 +74,12 @@ describe('HistoryController', function() {
)
})
return it('should set the flag for project history to true', function() {
it('should set the flag for project history to true', function() {
return this.req.useProjectHistory.should.equal(true)
})
})
return describe('for any other project ', function() {
describe('for any other project ', function() {
beforeEach(function() {
this.ProjectDetailsHandler.getDetails = sinon
.stub()
@@ -91,7 +91,7 @@ describe('HistoryController', function() {
)
})
return it('should not set the flag for project history to false', function() {
it('should not set the flag for project history to false', function() {
return this.req.useProjectHistory.should.equal(false)
})
})
@@ -140,7 +140,7 @@ describe('HistoryController', function() {
.should.equal(true)
})
return it('should pipe the response to the client', function() {
it('should pipe the response to the client', function() {
return this.proxy.pipe.calledWith(this.res).should.equal(true)
})
})
@@ -173,12 +173,12 @@ describe('HistoryController', function() {
.should.equal(true)
})
return it('should pipe the response to the client', function() {
it('should pipe the response to the client', function() {
return this.proxy.pipe.calledWith(this.res).should.equal(true)
})
})
return describe('with an error', function() {
describe('with an error', function() {
beforeEach(function() {
this.HistoryController.proxyToHistoryApi(this.req, this.res, this.next)
return this.proxy.events['error'].call(
@@ -187,7 +187,7 @@ describe('HistoryController', function() {
)
})
return it('should pass the error up the call chain', function() {
it('should pass the error up the call chain', function() {
return this.next.calledWith(this.error).should.equal(true)
})
})
@@ -239,12 +239,12 @@ describe('HistoryController', function() {
.should.equal(true)
})
return it('should return the data with users to the client', function() {
it('should return the data with users to the client', function() {
return this.res.json.calledWith(this.data_with_users).should.equal(true)
})
})
return describe('for a project without the project history flag', function() {
describe('for a project without the project history flag', function() {
beforeEach(function() {
this.req.useProjectHistory = false
return this.HistoryController.proxyToHistoryApiAndInjectUserDetails(
@@ -279,7 +279,7 @@ describe('HistoryController', function() {
.should.equal(true)
})
return it('should return the data with users to the client', function() {
it('should return the data with users to the client', function() {
return this.res.json.calledWith(this.data_with_users).should.equal(true)
})
})
@@ -307,12 +307,12 @@ describe('HistoryController', function() {
.should.equal(false)
})
return it('should not return the data with users to the client', function() {
it('should not return the data with users to the client', function() {
return this.res.json.calledWith(this.data_with_users).should.equal(false)
})
})
return describe('resyncProjectHistory', function() {
describe('resyncProjectHistory', function() {
describe('for a project without project-history enabled', function() {
beforeEach(function() {
this.project_id = 'mock-project-id'
@@ -332,12 +332,12 @@ describe('HistoryController', function() {
)
})
return it('response with a 404', function() {
it('response with a 404', function() {
return this.res.sendStatus.calledWith(404).should.equal(true)
})
})
return describe('for a project with project-history enabled', function() {
describe('for a project with project-history enabled', function() {
beforeEach(function() {
this.project_id = 'mock-project-id'
this.req = { params: { Project_id: this.project_id } }
@@ -361,7 +361,7 @@ describe('HistoryController', function() {
.should.equal(true)
})
return it('responds with a 204', function() {
it('responds with a 204', function() {
return this.res.sendStatus.calledWith(204).should.equal(true)
})
})
@@ -67,7 +67,7 @@ describe('HistoryManager', function() {
.should.equal(true)
})
return it('should return the callback with the overleaf id', function() {
it('should return the callback with the overleaf id', function() {
return this.callback
.calledWithExactly(null, { overleaf_id: this.overleaf_id })
.should.equal(true)
@@ -85,7 +85,7 @@ describe('HistoryManager', function() {
return this.HistoryManager.initializeProject(this.callback)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
sinon.match.has(
@@ -105,7 +105,7 @@ describe('HistoryManager', function() {
return this.HistoryManager.initializeProject(this.callback)
})
return it('should return the callback with an error', function() {
it('should return the callback with an error', function() {
return this.callback
.calledWith(
sinon.match.has(
@@ -117,7 +117,7 @@ describe('HistoryManager', function() {
})
})
return describe('project history errors', function() {
describe('project history errors', function() {
beforeEach(function() {
this.error = sinon.stub()
this.request.post = sinon.stub().callsArgWith(1, this.error)
@@ -125,25 +125,25 @@ describe('HistoryManager', function() {
return this.HistoryManager.initializeProject(this.callback)
})
return it('should return the callback with the error', function() {
it('should return the callback with the error', function() {
return this.callback.calledWithExactly(this.error).should.equal(true)
})
})
})
return describe('with project history disabled', function() {
describe('with project history disabled', function() {
beforeEach(function() {
this.settings.apis.project_history.initializeHistoryForNewProjects = false
return this.HistoryManager.initializeProject(this.callback)
})
return it('should return the callback', function() {
it('should return the callback', function() {
return this.callback.calledWithExactly().should.equal(true)
})
})
})
return describe('injectUserDetails', function() {
describe('injectUserDetails', function() {
beforeEach(function() {
this.user1 = {
_id: (this.user_id1 = '123456'),
@@ -202,7 +202,7 @@ describe('HistoryManager', function() {
)
})
return it('should leave user objects', function(done) {
it('should leave user objects', function(done) {
return this.HistoryManager.injectUserDetails(
{
diff: [
@@ -230,7 +230,7 @@ describe('HistoryManager', function() {
})
})
return describe('with a list of updates', function() {
describe('with a list of updates', function() {
it('should turn user_ids into user objects', function(done) {
return this.HistoryManager.injectUserDetails(
{
@@ -264,7 +264,7 @@ describe('HistoryManager', function() {
)
})
return it('should leave user objects', function(done) {
it('should leave user objects', function(done) {
return this.HistoryManager.injectUserDetails(
{
updates: [
@@ -98,12 +98,12 @@ describe('RestoreManager', function() {
.should.equal(true)
})
return it('should call the callback with the entity', function() {
it('should call the callback with the entity', function() {
return this.callback.calledWith(null, this.entity).should.equal(true)
})
})
return describe('with a file in a folder', function() {
describe('with a file in a folder', function() {
beforeEach(function() {
this.pathname = 'foo/bar.tex'
return this.RestoreManager.restoreFileFromV2(
@@ -121,7 +121,7 @@ describe('RestoreManager', function() {
.should.equal(true)
})
return it('should add the entity by its basename', function() {
it('should add the entity by its basename', function() {
return this.FileSystemImportManager.addEntity
.calledWith(
this.user_id,
@@ -154,12 +154,12 @@ describe('RestoreManager', function() {
.should.equal(true)
})
return it('should return the folder_id', function() {
it('should return the folder_id', function() {
return this.callback.calledWith(null, this.folder_id).should.equal(true)
})
})
return describe('_addEntityWithUniqueName', function() {
describe('_addEntityWithUniqueName', function() {
beforeEach(function() {
this.addEntityWithName = sinon.stub()
return (this.name = 'foo.tex')
@@ -179,12 +179,12 @@ describe('RestoreManager', function() {
return this.addEntityWithName.calledWith(this.name).should.equal(true)
})
return it('should return the entity', function() {
it('should return the entity', function() {
return this.callback.calledWith(null, this.entity).should.equal(true)
})
})
return describe('with an invalid name', function() {
describe('with an invalid name', function() {
beforeEach(function() {
this.addEntityWithName
.onFirstCall()
@@ -210,7 +210,7 @@ describe('RestoreManager', function() {
.should.equal(true)
})
return it('should return the entity', function() {
it('should return the entity', function() {
return this.callback.calledWith(null, this.entity).should.equal(true)
})
})
@@ -92,7 +92,7 @@ describe('InactiveProjectManager', function() {
)
})
return it('should not call unarchiveProject if it is active', function(done) {
it('should not call unarchiveProject if it is active', function(done) {
this.project.active = true
this.DocstoreManager.unarchiveProject.callsArgWith(1)
return this.InactiveProjectManager.reactivateProjectIfRequired(
@@ -110,7 +110,7 @@ describe('InactiveProjectManager', function() {
})
})
return describe('deactivateProject', function() {
describe('deactivateProject', function() {
it('should call unarchiveProject and markAsInactive', function(done) {
this.DocstoreManager.archiveProject.callsArgWith(1)
this.TrackChangesManager.archiveProject.callsArgWith(1)
@@ -132,7 +132,7 @@ describe('InactiveProjectManager', function() {
)
})
return it('should not call markAsInactive if there was a problem archiving in docstore', function(done) {
it('should not call markAsInactive if there was a problem archiving in docstore', function(done) {
this.DocstoreManager.archiveProject.callsArgWith(1, 'errorrr')
this.TrackChangesManager.archiveProject.callsArgWith(1)
@@ -75,7 +75,7 @@ describe('InstitutionsAPI', function() {
)
})
return it('handle empty response', function(done) {
it('handle empty response', function(done) {
this.settings.apis = null
return this.InstitutionsAPI.getInstitutionAffiliations(
this.institutionId,
@@ -158,7 +158,7 @@ describe('InstitutionsAPI', function() {
)
})
return it('handle empty response', function(done) {
it('handle empty response', function(done) {
this.settings.apis = null
return this.InstitutionsAPI.getUserAffiliations(
this.stubbedUser._id,
@@ -211,7 +211,7 @@ describe('InstitutionsAPI', function() {
)
})
return it('handle error', function(done) {
it('handle error', function(done) {
const body = { errors: 'affiliation error message' }
this.request.callsArgWith(1, null, { statusCode: 422 }, body)
return this.InstitutionsAPI.addAffiliation(
@@ -252,7 +252,7 @@ describe('InstitutionsAPI', function() {
)
})
return it('handle error', function(done) {
it('handle error', function(done) {
this.request.callsArgWith(1, null, { statusCode: 500 })
return this.InstitutionsAPI.removeAffiliation(
this.stubbedUser._id,
@@ -285,7 +285,7 @@ describe('InstitutionsAPI', function() {
)
})
return it('handle error', function(done) {
it('handle error', function(done) {
const body = { errors: 'affiliation error message' }
this.request.callsArgWith(1, null, { statusCode: 518 }, body)
return this.InstitutionsAPI.deleteAffiliations(
@@ -300,12 +300,12 @@ describe('InstitutionsAPI', function() {
})
})
return describe('endorseAffiliation', function() {
describe('endorseAffiliation', function() {
beforeEach(function() {
return this.request.callsArgWith(1, null, { statusCode: 204 })
})
return it('endorse affiliation', function(done) {
it('endorse affiliation', function(done) {
return this.InstitutionsAPI.endorseAffiliation(
this.stubbedUser._id,
this.newEmail,
@@ -74,7 +74,7 @@ describe('InstitutionsController', function() {
return (this.next = sinon.stub())
})
return describe('affiliateUsers', function() {
describe('affiliateUsers', function() {
it('should add affiliations for matching users', function(done) {
this.res.sendStatus = code => {
code.should.equal(200)
@@ -104,7 +104,7 @@ describe('InstitutionsController', function() {
)
})
return it('should return errors if last affiliation cannot be added', function(done) {
it('should return errors if last affiliation cannot be added', function(done) {
this.addAffiliation.onCall(2).callsArgWith(3, new Error('error'))
this.next = error => {
expect(error).to.exist
@@ -86,7 +86,7 @@ describe('InstitutionsFeatures', function() {
})
})
return it('should return true if user has confirmed paid affiliation', function(done) {
it('should return true if user has confirmed paid affiliation', function(done) {
const institutions = [
{ licence: 'pro_plus' },
{ licence: 'free' },
@@ -140,7 +140,7 @@ describe('InstitutionsFeatures', function() {
)
})
return it('should return feaures if user has affiliations plan code', function(done) {
it('should return feaures if user has affiliations plan code', function(done) {
this.InstitutionsFeatures.getInstitutionsPlan.yields(
null,
this.institutionPlanCode
@@ -156,7 +156,7 @@ describe('InstitutionsFeatures', function() {
})
})
return describe('getInstitutionsPlan', function() {
describe('getInstitutionsPlan', function() {
beforeEach(function() {
return (this.InstitutionsFeatures.hasLicence = sinon.stub())
})
@@ -184,7 +184,7 @@ describe('InstitutionsFeatures', function() {
)
})
return it('should return plan if user has licence', function(done) {
it('should return plan if user has licence', function(done) {
this.InstitutionsFeatures.hasLicence.yields(null, true)
return this.InstitutionsFeatures.getInstitutionsPlan(
this.userId,
@@ -38,7 +38,7 @@ describe('InstitutionsGetter', function() {
return (this.userId = '12345abcde')
})
return describe('getConfirmedInstitutions', function() {
describe('getConfirmedInstitutions', function() {
it('filters unconfirmed affiliations', function(done) {
this.userEmails = [
{
@@ -80,7 +80,7 @@ describe('InstitutionsGetter', function() {
)
})
return it('should handle error', function(done) {
it('should handle error', function(done) {
this.UserGetter.getUserFullEmails.yields(new Error('Nope'))
return this.InstitutionsGetter.getConfirmedInstitutions(
this.userId,
@@ -135,7 +135,7 @@ describe('InstitutionsManager', function() {
)
})
return it('notifies users if they have a subscription that should be cancelled', function(done) {
it('notifies users if they have a subscription that should be cancelled', function(done) {
return this.InstitutionsManager.upgradeInstitutionUsers(
this.institutionId,
error => {
@@ -189,7 +189,7 @@ describe('InstitutionsManager', function() {
)
}))
return describe('getInstitutionUsersSubscriptions', () =>
describe('getInstitutionUsersSubscriptions', () =>
it('returns all institution users subscriptions', function(done) {
const stubbedUsers = [
{ user_id: '123abc123abc123abc123abc' },
@@ -68,7 +68,7 @@ describe('MetaController', function() {
])
})
return describe('when MetaHandler.getAllMetaForProject produces an error', function() {
describe('when MetaHandler.getAllMetaForProject produces an error', function() {
beforeEach(function() {
this.MetaHandler.getAllMetaForProject = sinon
.stub()
@@ -92,14 +92,14 @@ describe('MetaController', function() {
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
})
return it('should not send a json response', function() {
it('should not send a json response', function() {
this.MetadataController.getMetadata(this.req, this.res, this.next)
return this.res.json.callCount.should.equal(0)
})
})
})
return describe('broadcastMetadataForDoc', function() {
describe('broadcastMetadataForDoc', function() {
beforeEach(function() {
this.MetaHandler.getMetaForDoc = sinon
.stub()
@@ -155,7 +155,7 @@ describe('MetaController', function() {
return expect(lastCall.args[2]).to.have.all.keys(['docId', 'meta'])
})
return describe('when MetaHandler.getMetaForDoc produces an error', function() {
describe('when MetaHandler.getMetaForDoc produces an error', function() {
beforeEach(function() {
this.MetaHandler.getMetaForDoc = sinon
.stub()
@@ -191,7 +191,7 @@ describe('MetaController', function() {
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
})
return it('should not send a json response', function() {
it('should not send a json response', function() {
this.MetadataController.broadcastMetadataForDoc(
this.req,
this.res,
@@ -77,7 +77,7 @@ describe('MetaHandler', function() {
])
})
return it('should extract all the labels and packages', function() {
it('should extract all the labels and packages', function() {
const docMeta = this.MetaHandler.extractMetaFromDoc(this.lines)
return expect(docMeta).to.deep.equal({
labels: ['aaa', 'bbb'],
@@ -137,7 +137,7 @@ describe('MetaHandler', function() {
})
})
return it('should extract all metadata', function() {
it('should extract all metadata', function() {
const projectMeta = this.MetaHandler.extractMetaFromProjectDocs(this.docs)
return expect(projectMeta).to.deep.equal({
id_one: { labels: ['aaa'], packages: {} },
@@ -241,7 +241,7 @@ describe('MetaHandler', function() {
})
})
return it('should call extractMetaFromDoc', function(done) {
it('should call extractMetaFromDoc', function(done) {
return this.call((err, docMeta) => {
this.MetaHandler.extractMetaFromDoc.callCount.should.equal(1)
this.MetaHandler.extractMetaFromDoc
@@ -252,7 +252,7 @@ describe('MetaHandler', function() {
})
})
return describe('getAllMetaForProject', function() {
describe('getAllMetaForProject', function() {
beforeEach(function() {
this.fakeDocs = {
doc_one: {
@@ -317,7 +317,7 @@ describe('MetaHandler', function() {
})
})
return it('should call extractMetaFromDoc', function(done) {
it('should call extractMetaFromDoc', function(done) {
return this.call((err, docMeta) => {
this.MetaHandler.extractMetaFromProjectDocs.callCount.should.equal(1)
this.MetaHandler.extractMetaFromProjectDocs
@@ -46,7 +46,7 @@ describe('NotificationsBuilder', function() {
}))
})
return it('should call v1 and create affiliation notifications', function(done) {
it('should call v1 and create affiliation notifications', function(done) {
const ip = '192.168.0.1'
return this.controller
.ipMatcherAffiliation(user_id)
@@ -77,7 +77,7 @@ describe('NotificationsController', function() {
})
})
return it('should send a delete request when a delete has been received to mark a notification', function(done) {
it('should send a delete request when a delete has been received to mark a notification', function(done) {
return this.controller.markNotificationAsRead(this.req, {
send: () => {
this.handler.markAsRead
@@ -68,7 +68,7 @@ describe('NotificationsHandler', function() {
)
})
return it('should return empty arrays if there are no notifications', function() {
it('should return empty arrays if there are no notifications', function() {
this.request.callsArgWith(1, null, { statusCode: 200 }, null)
return this.handler.getUserNotifications(
user_id,
@@ -84,7 +84,7 @@ describe('NotificationsHandler', function() {
return (this.key = 'some key here')
})
return it('should send a delete request when a delete has been received to mark a notification', function(done) {
it('should send a delete request when a delete has been received to mark a notification', function(done) {
return this.handler.markAsReadWithKey(user_id, this.key, () => {
const opts = {
uri: `${notificationUrl}/user/${user_id}`,
@@ -131,7 +131,7 @@ describe('NotificationsHandler', function() {
)
})
return describe('when expiry date is supplied', function() {
describe('when expiry date is supplied', function() {
beforeEach(function() {
this.key = 'some key here'
this.messageOpts = { value: 12344 }
@@ -139,7 +139,7 @@ describe('NotificationsHandler', function() {
return (this.expiry = new Date())
})
return it('should post the message over with expiry field', function(done) {
it('should post the message over with expiry field', function(done) {
return this.handler.createNotification(
user_id,
this.key,
@@ -165,12 +165,12 @@ describe('NotificationsHandler', function() {
})
})
return describe('markAsReadByKeyOnly', function() {
describe('markAsReadByKeyOnly', function() {
beforeEach(function() {
return (this.key = 'some key here')
})
return it('should send a delete request when a delete has been received to mark a notification', function(done) {
it('should send a delete request when a delete has been received to mark a notification', function(done) {
return this.handler.markAsReadByKeyOnly(this.key, () => {
const opts = {
uri: `${notificationUrl}/key/${this.key}`,
@@ -150,7 +150,7 @@ describe('PasswordResetController', function() {
return this.PasswordResetController.requestReset(this.req, this.res)
})
return it('should lowercase the email address', function(done) {
it('should lowercase the email address', function(done) {
this.email = 'UPerCaseEMAIL@example.Com'
this.req.body.email = this.email
this.RateLimiter.addCount.callsArgWith(1, null, true)
@@ -285,7 +285,7 @@ describe('PasswordResetController', function() {
return this.PasswordResetController.setNewUserPassword(this.req, this.res)
})
return describe('when login_after is set', function() {
describe('when login_after is set', function() {
beforeEach(function() {
this.UserGetter.getUser = sinon
.stub()
@@ -306,7 +306,7 @@ describe('PasswordResetController', function() {
.returns('/some/path'))
})
return it('should login user if login_after is set', function(done) {
it('should login user if login_after is set', function(done) {
this.PasswordResetController.setNewUserPassword(this.req, this.res)
this.AuthenticationController.afterLoginSessionSetup.callCount.should.equal(
1
@@ -324,13 +324,13 @@ describe('PasswordResetController', function() {
})
})
return describe('renderSetPasswordForm', function() {
describe('renderSetPasswordForm', function() {
describe('with token in query-string', function() {
beforeEach(function() {
return (this.req.query.passwordResetToken = this.token)
})
return it('should set session.resetToken and redirect', function(done) {
it('should set session.resetToken and redirect', function(done) {
this.req.session.should.not.have.property('resetToken')
this.res.redirect = path => {
path.should.equal('/user/password/set')
@@ -344,13 +344,13 @@ describe('PasswordResetController', function() {
})
})
return describe('without a token in query-string', function() {
describe('without a token in query-string', function() {
describe('with token in session', function() {
beforeEach(function() {
return (this.req.session.resetToken = this.token)
})
return it('should render the page, passing the reset token', function(done) {
it('should render the page, passing the reset token', function(done) {
this.res.render = (template_path, options) => {
options.passwordResetToken.should.equal(this.req.session.resetToken)
return done()
@@ -362,7 +362,7 @@ describe('PasswordResetController', function() {
})
})
return describe('without a token in session', () =>
describe('without a token in session', () =>
it('should redirect to the reset request page', function(done) {
this.res.redirect = path => {
path.should.equal('/user/password/reset')
@@ -98,7 +98,7 @@ describe('PasswordResetHandler', function() {
)
})
return it('should return exists == null for a holdingAccount', function(done) {
it('should return exists == null for a holdingAccount', function(done) {
this.user.holdingAccount = true
this.UserGetter.getUserByMainEmail.callsArgWith(1, null, this.user)
this.UserGetter.getUserByAnyEmail.callsArgWith(1)
@@ -113,7 +113,7 @@ describe('PasswordResetHandler', function() {
})
})
return describe('when in overleaf', function() {
describe('when in overleaf', function() {
beforeEach(function() {
return (this.settings.overleaf = true)
})
@@ -160,7 +160,7 @@ describe('PasswordResetHandler', function() {
)
})
return it('should return status == true', function() {
it('should return status == true', function() {
return this.callback.calledWith(null, 'primary').should.equal(true)
})
})
@@ -185,7 +185,7 @@ describe('PasswordResetHandler', function() {
return this.EmailHandler.sendEmail.called.should.equal(false)
})
return it('should return status == null', function() {
it('should return status == null', function() {
return this.callback.calledWith(null, null).should.equal(true)
})
})
@@ -210,12 +210,12 @@ describe('PasswordResetHandler', function() {
return this.EmailHandler.sendEmail.called.should.equal(false)
})
return it('should return status == sharelatex', function() {
it('should return status == sharelatex', function() {
return this.callback.calledWith(null, 'sharelatex').should.equal(true)
})
})
return describe('when the email is a secondary email', function() {
describe('when the email is a secondary email', function() {
beforeEach(function() {
this.V1Api.request = sinon
.stub()
@@ -236,14 +236,14 @@ describe('PasswordResetHandler', function() {
return this.EmailHandler.sendEmail.called.should.equal(false)
})
return it('should return status == secondary', function() {
it('should return status == secondary', function() {
return this.callback.calledWith(null, 'secondary').should.equal(true)
})
})
})
})
return describe('setNewUserPassword', function() {
describe('setNewUserPassword', function() {
describe('when no data is found', function() {
beforeEach(function() {
this.OneTimeTokenHandler.getValueFromTokenAndExpire.yields(null, null)
@@ -254,7 +254,7 @@ describe('PasswordResetHandler', function() {
)
})
return it('should return exists == false', function() {
it('should return exists == false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
@@ -283,14 +283,14 @@ describe('PasswordResetHandler', function() {
.should.equal(true)
})
return it('should reset == true and the user_id', function() {
it('should reset == true and the user_id', function() {
return this.callback
.calledWith(null, true, this.user_id)
.should.equal(true)
})
})
return describe('when the data is a new style user_id', function() {
describe('when the data is a new style user_id', function() {
beforeEach(function() {
this.AuthenticationManager.setUserPassword.yields(
null,
@@ -313,7 +313,7 @@ describe('PasswordResetHandler', function() {
.should.equal(true)
})
return it('should reset == true and the user_id', function() {
it('should reset == true and the user_id', function() {
return this.callback
.calledWith(null, true, this.user_id)
.should.equal(true)
@@ -89,7 +89,7 @@ describe('doc lines comparitor', function() {
return result.should.equal(true)
})
return it('should return false when comparing different orchard docs', function() {
it('should return false when comparing different orchard docs', function() {
const lines1 = [{ text: 'goodbye world' }]
const lines2 = [{ text: 'hello world' }]
const result = this.comparitor.areSame(lines1, lines2)
@@ -41,7 +41,7 @@ describe('Project api controller', function() {
return (this.projDetails = { name: 'something' })
})
return describe('getProjectDetails', function() {
describe('getProjectDetails', function() {
it('should ask the project details handler for proj details', function(done) {
this.ProjectDetailsHandler.getDetails.callsArgWith(
1,
@@ -58,7 +58,7 @@ describe('Project api controller', function() {
return this.controller.getProjectDetails(this.req, this.res)
})
return it('should send a 500 if there is an error', function() {
it('should send a 500 if there is an error', function() {
this.ProjectDetailsHandler.getDetails.callsArgWith(1, 'error')
this.controller.getProjectDetails(this.req, this.res, this.next)
return this.next.calledWith('error').should.equal(true)
@@ -55,7 +55,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should update project model', function() {
it('should update project model', function() {
const update = {
$set: {
collabratecUsers: [
@@ -87,12 +87,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback).to.have.been.calledWith('error')
})
})
return describe('with invalid args', function() {
describe('with invalid args', function() {
beforeEach(function() {
this.ProjectModel.update = sinon.stub()
return this.ProjectCollabratecDetailsHandler.initializeCollabratecProject(
@@ -108,7 +108,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
@@ -143,12 +143,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with true', function() {
it('should callback with true', function() {
return expect(this.callback).to.have.been.calledWith(null, true)
})
})
return describe('when user project found', function() {
describe('when user project found', function() {
beforeEach(function() {
this.ProjectModel.findOne = sinon.stub().yields(null, null)
return this.ProjectCollabratecDetailsHandler.isLinkedCollabratecUserProject(
@@ -158,7 +158,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with false', function() {
it('should callback with false', function() {
return expect(this.callback).to.have.been.calledWith(null, false)
})
})
@@ -174,12 +174,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback).to.have.been.calledWith('error')
})
})
return describe('with invalid args', function() {
describe('with invalid args', function() {
beforeEach(function() {
this.ProjectModel.findOne = sinon.stub()
return this.ProjectCollabratecDetailsHandler.isLinkedCollabratecUserProject(
@@ -193,7 +193,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.findOne).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
@@ -211,7 +211,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should update project model', function() {
it('should update project model', function() {
const query = {
_id: this.projectId,
collabratecUsers: {
@@ -250,12 +250,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback).to.have.been.calledWith('error')
})
})
return describe('with invalid args', function() {
describe('with invalid args', function() {
beforeEach(function() {
this.ProjectModel.update = sinon.stub()
return this.ProjectCollabratecDetailsHandler.linkCollabratecUserProject(
@@ -270,7 +270,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
@@ -302,7 +302,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should update project model', function() {
it('should update project model', function() {
const update = {
$set: {
collabratecUsers: this.collabratecUsers
@@ -326,7 +326,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback).to.have.been.calledWith('error')
})
})
@@ -345,12 +345,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
return describe('with invalid user_id', function() {
describe('with invalid user_id', function() {
beforeEach(function() {
this.collabratecUsers[1].user_id = 'bad-user-id'
this.ProjectModel.update = sinon.stub()
@@ -365,7 +365,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
@@ -382,7 +382,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should update project model', function() {
it('should update project model', function() {
const query = { _id: this.projectId }
const update = {
$pull: {
@@ -409,12 +409,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback).to.have.been.calledWith('error')
})
})
return describe('with invalid args', function() {
describe('with invalid args', function() {
beforeEach(function() {
this.ProjectModel.update = sinon.stub()
return this.ProjectCollabratecDetailsHandler.unlinkCollabratecUserProject(
@@ -428,13 +428,13 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
})
return describe('updateCollabratecUserIds', function() {
describe('updateCollabratecUserIds', function() {
describe('when update succeeds', function() {
beforeEach(function() {
this.ProjectModel.update = sinon.stub().yields()
@@ -445,7 +445,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should update project model', function() {
it('should update project model', function() {
return expect(this.ProjectModel.update).to.have.been.calledWith(
{ 'collabratecUsers.user_id': this.userId },
{ $set: { 'collabratecUsers.$.user_id': this.userId2 } },
@@ -465,7 +465,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback).to.have.been.calledWith('error')
})
})
@@ -484,12 +484,12 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
return describe('with invalid new_user_id', function() {
describe('with invalid new_user_id', function() {
beforeEach(function() {
this.ProjectModel.update = sinon.stub()
return this.ProjectCollabratecDetailsHandler.updateCollabratecUserIds(
@@ -503,7 +503,7 @@ describe('ProjectCollabratecDetailsHandler', function() {
return expect(this.ProjectModel.update).not.to.have.beenCalled
})
return it('should callback with error', function() {
it('should callback with error', function() {
return expect(this.callback.firstCall.args[0]).to.be.instanceOf(Error)
})
})
@@ -246,7 +246,7 @@ describe('ProjectController', function() {
return this.ProjectController.updateProjectSettings(this.req, this.res)
})
return it('should update the root doc', function(done) {
it('should update the root doc', function(done) {
this.EditorController.setRootDoc = sinon.stub().callsArg(2)
this.req.body = { rootDocId: (this.rootDocId = 'root-doc-id') }
this.res.sendStatus = code => {
@@ -291,7 +291,7 @@ describe('ProjectController', function() {
return this.ProjectController.deleteProject(this.req, this.res)
})
return it('should tell the project deleter to delete when forever=true', function(done) {
it('should tell the project deleter to delete when forever=true', function(done) {
this.req.query = { forever: 'true' }
this.res.sendStatus = code => {
this.ProjectDeleter.deleteProject
@@ -346,7 +346,7 @@ describe('ProjectController', function() {
return this.ProjectController.newProject(this.req, this.res)
})
return it('should call the projectCreationHandler with createBasicProject', function(done) {
it('should call the projectCreationHandler with createBasicProject', function(done) {
this.req.body.template = 'basic'
this.res.send = json => {
this.ProjectCreationHandler.createExampleProject.called.should.equal(
@@ -530,7 +530,7 @@ describe('ProjectController', function() {
return this.ProjectController.projectListPage(this.req, this.res)
})
return it('should not show for non sample users', function(done) {
it('should not show for non sample users', function(done) {
this.user._id = '588f3ddae8ebc1bac07c9fff' // last two digits
this.res.render = (pageName, opts) => {
expect(opts.frontChatWidgetRoomId).to.equal(undefined)
@@ -540,7 +540,7 @@ describe('ProjectController', function() {
})
})
return describe('with overleaf-integration-web-module hook', function() {
describe('with overleaf-integration-web-module hook', function() {
beforeEach(function() {
this.V1Response = {
projects: [
@@ -603,7 +603,7 @@ describe('ProjectController', function() {
return this.ProjectController.projectListPage(this.req, this.res)
})
return it('should have isShowingV1Projects flag', function(done) {
it('should have isShowingV1Projects flag', function(done) {
this.res.render = (pageName, opts) => {
opts.isShowingV1Projects.should.equal(true)
return done()
@@ -678,7 +678,7 @@ describe('ProjectController', function() {
return this.ProjectController.projectListPage(this.req, this.res)
})
return it('should omit one of the projects', function(done) {
it('should omit one of the projects', function(done) {
this.res.render = (pageName, opts) => {
opts.projects.length.should.equal(
this.projects.length +
@@ -712,7 +712,7 @@ describe('ProjectController', function() {
return this.ProjectController.renameProject(this.req, this.res)
})
return it('should send an error to next() if there is a problem', function(done) {
it('should send an error to next() if there is a problem', function(done) {
let error
this.EditorController.renameProject.callsArgWith(
2,
@@ -848,7 +848,7 @@ describe('ProjectController', function() {
return this.ProjectController.loadEditor(this.req, this.res)
})
return it('should expose the brand variation details as locals for branded projects', function(done) {
it('should expose the brand variation details as locals for branded projects', function(done) {
this.ProjectGetter.getProject.callsArgWith(2, null, this.brandedProject)
this.res.render = (pageName, opts) => {
opts.brandVariation.should.deep.equal(this.brandVariationDetails)
@@ -900,7 +900,7 @@ describe('ProjectController', function() {
return done()
})
return it('should produce a list of projects', function(done) {
it('should produce a list of projects', function(done) {
this.res.json = data => {
expect(data).to.deep.equal({
projects: [
@@ -939,7 +939,7 @@ describe('ProjectController', function() {
.callsArgWith(1, null, this.docs, this.files))
})
return it('should produce a list of entities', function(done) {
it('should produce a list of entities', function(done) {
this.res.json = data => {
expect(data).to.deep.equal({
project_id: 'abcd',
@@ -963,7 +963,7 @@ describe('ProjectController', function() {
})
})
return describe('_isInPercentageRollout', function() {
describe('_isInPercentageRollout', function() {
before(function() {
return (this.ids = [
'5a05cd7621f9fe22be131740',
@@ -989,7 +989,7 @@ describe('ProjectController', function() {
])
})
return it('should produce the expected results', function() {
it('should produce the expected results', function() {
expect(
this.ids.map(i => {
return this.ProjectController._isInPercentageRollout('abcd', i, 50)
@@ -286,7 +286,7 @@ describe('ProjectCreationHandler', function() {
)
})
return it('should send a project-imported event when importing a project', function(done) {
it('should send a project-imported event when importing a project', function(done) {
const attributes = {
overleaf: {
history: {
@@ -324,12 +324,12 @@ describe('ProjectCreationHandler', function() {
)
})
return it('should return the error to the callback', function() {
it('should return the error to the callback', function() {
return should.exist(this.callback.args[0][0])
})
})
return describe('with an invalid name', function() {
describe('with an invalid name', function() {
beforeEach(function() {
this.ProjectDetailsHandler.validateProjectName = sinon
.stub()
@@ -345,7 +345,7 @@ describe('ProjectCreationHandler', function() {
return should.exist(this.callback.args[0][0])
})
return it('should not try to create the project', function() {
it('should not try to create the project', function() {
return this.ProjectModel.prototype.save.called.should.equal(false)
})
})
@@ -391,7 +391,7 @@ describe('ProjectCreationHandler', function() {
.should.equal(true)
})
return it('should build the mainbasic.tex template', function() {
it('should build the mainbasic.tex template', function() {
return this.handler._buildTemplate
.calledWith('mainbasic.tex', ownerId, projectName)
.should.equal(true)
@@ -421,7 +421,7 @@ describe('ProjectCreationHandler', function() {
.should.equal(true)
})
return it('should create the root document', function() {
it('should create the root document', function() {
return this.handler._createRootDoc
.calledWith(this.project, ownerId, ['snippet line 1', 'snippet line 2'])
.should.equal(true)
@@ -504,7 +504,7 @@ describe('ProjectCreationHandler', function() {
.should.equal(true)
})
return it('should build the references.bib template', function() {
it('should build the references.bib template', function() {
return this.handler._buildTemplate
.calledWith('references.bib', ownerId, projectName)
.should.equal(true)
@@ -548,13 +548,13 @@ describe('ProjectCreationHandler', function() {
return done()
})
return it('should put the year in', function(done) {
it('should put the year in', function(done) {
this.template.indexOf(new Date().getUTCFullYear()).should.not.equal(-1)
return done()
})
})
return describe('_createRootDoc', function() {
describe('_createRootDoc', function() {
beforeEach(function(done) {
this.project = new this.ProjectModel()
@@ -578,7 +578,7 @@ describe('ProjectCreationHandler', function() {
.should.equal(true)
})
return it('should set the main doc id', function() {
it('should set the main doc id', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(project_id, docId)
.should.equal(true)
@@ -99,7 +99,7 @@ describe('ProjectDeleter', function() {
})
})
return it('should tell the editor controler so users are notified', function(done) {
it('should tell the editor controler so users are notified', function(done) {
return this.deleter.markAsDeletedByExternalSource(project_id, () => {
this.editorController.notifyUsersProjectHasBeenDeletedOrRenamed
.calledWith(project_id)
@@ -122,7 +122,7 @@ describe('ProjectDeleter', function() {
)
})
return it('should remove the flag from the project', function() {
it('should remove the flag from the project', function() {
return this.Project.update
.calledWith(
{ _id: this.project_id },
@@ -164,7 +164,7 @@ describe('ProjectDeleter', function() {
})
})
return it('should remove all the projects the user is a collaborator of', function(done) {
it('should remove all the projects the user is a collaborator of', function(done) {
return this.deleter.deleteUsersProjects(this.user._id, () => {
this.CollaboratorsHandler.removeUserFromAllProjets
.calledWith(this.user._id)
@@ -218,7 +218,7 @@ describe('ProjectDeleter', function() {
})
})
return it('should remove the project from Mongo', function(done) {
it('should remove the project from Mongo', function(done) {
return this.deleter.deleteProject(this.project_id, () => {
this.Project.remove
.calledWith({
@@ -235,7 +235,7 @@ describe('ProjectDeleter', function() {
return this.Project.update.callsArgWith(2)
})
return it('should update the project', function(done) {
it('should update the project', function(done) {
return this.deleter.archiveProject(this.project_id, () => {
this.Project.update
.calledWith(
@@ -252,12 +252,12 @@ describe('ProjectDeleter', function() {
})
})
return describe('restoreProject', function() {
describe('restoreProject', function() {
beforeEach(function() {
return this.Project.update.callsArgWith(2)
})
return it('should unset the archive attribute', function(done) {
it('should unset the archive attribute', function(done) {
return this.deleter.restoreProject(this.project_id, () => {
this.Project.update
.calledWith(
@@ -114,7 +114,7 @@ describe('ProjectDetailsHandler', function() {
})
})
return it('should return the error', function(done) {
it('should return the error', function(done) {
const error = 'some error'
this.ProjectGetter.getProject.callsArgWith(2, error)
return this.handler.getDetails(this.project_id, err => {
@@ -206,7 +206,7 @@ describe('ProjectDetailsHandler', function() {
})
})
return it('should append the supplied suffix to the project name, if passed', function(done) {
it('should append the supplied suffix to the project name, if passed', function(done) {
return this.handler.transferOwnership('abc', '123', ' wombat', () => {
sinon.assert.calledWith(
this.handler.generateUniqueName,
@@ -232,7 +232,7 @@ describe('ProjectDetailsHandler', function() {
)
})
return it('should return what the mongo call returns', function(done) {
it('should return what the mongo call returns', function(done) {
const err = 'error'
const description = 'cool project'
this.ProjectGetter.getProject.callsArgWith(2, err, { description })
@@ -252,7 +252,7 @@ describe('ProjectDetailsHandler', function() {
return (this.description = 'updated teh description')
})
return it('should update the project detials', function(done) {
it('should update the project detials', function(done) {
this.ProjectModel.update.callsArgWith(2)
return this.handler.setProjectDescription(
this.project_id,
@@ -300,7 +300,7 @@ describe('ProjectDetailsHandler', function() {
})
})
return it('should not do anything with an invalid name', function(done) {
it('should not do anything with an invalid name', function(done) {
this.handler.validateProjectName = sinon
.stub()
.yields(new Error('invalid name'))
@@ -351,7 +351,7 @@ describe('ProjectDetailsHandler', function() {
)
})
return it('should accept normal names', function(done) {
it('should accept normal names', function(done) {
return this.handler.validateProjectName('foobar', function(error) {
expect(error).to.not.exist
return done()
@@ -516,7 +516,7 @@ describe('ProjectDetailsHandler', function() {
)
})
return it('should not find a numeric index lower than the one already present', function(done) {
it('should not find a numeric index lower than the one already present', function(done) {
return this.handler.ensureProjectNameIsUnique(
this.user_id,
'numeric (31)',
@@ -551,7 +551,7 @@ describe('ProjectDetailsHandler', function() {
).to.equal('a'.repeat(150))
})
return it('should accept normal names', function() {
it('should accept normal names', function() {
return expect(this.handler.fixProjectName('foobar')).to.equal('foobar')
})
})
@@ -589,12 +589,12 @@ describe('ProjectDetailsHandler', function() {
)
})
return describe('when update produces an error', function() {
describe('when update produces an error', function() {
beforeEach(function() {
return this.ProjectModel.update.callsArgWith(2, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.handler.setPublicAccessLevel(
this.project_id,
this.accessLevel,
@@ -608,7 +608,7 @@ describe('ProjectDetailsHandler', function() {
})
})
return describe('ensureTokensArePresent', function() {
describe('ensureTokensArePresent', function() {
beforeEach(function() {})
describe('when the project has tokens', function() {
@@ -652,7 +652,7 @@ describe('ProjectDetailsHandler', function() {
)
})
return it('should produce the tokens without error', function(done) {
it('should produce the tokens without error', function(done) {
return this.handler.ensureTokensArePresent(
this.project_id,
(err, tokens) => {
@@ -664,7 +664,7 @@ describe('ProjectDetailsHandler', function() {
})
})
return describe('when tokens are missing', function() {
describe('when tokens are missing', function() {
beforeEach(function() {
this.project = { _id: this.project_id }
this.ProjectGetter.getProject = sinon
@@ -728,7 +728,7 @@ describe('ProjectDetailsHandler', function() {
)
})
return it('should produce the tokens without error', function(done) {
it('should produce the tokens without error', function(done) {
return this.handler.ensureTokensArePresent(
this.project_id,
(err, tokens) => {
@@ -334,7 +334,7 @@ describe('ProjectDuplicator', function() {
)
})
return it('should copy all the files', function(done) {
it('should copy all the files', function(done) {
return this.duplicator.duplicate(
this.owner,
this.old_project_id,
@@ -376,7 +376,7 @@ describe('ProjectDuplicator', function() {
})
})
return describe('when there is an error', function() {
describe('when there is an error', function() {
beforeEach(function() {
return (this.rootFolder.fileRefs = [
{ name: 'file0', _id: 'file0' },
@@ -414,7 +414,7 @@ describe('ProjectDuplicator', function() {
)
})
return it('should return an error', function(done) {
it('should return an error', function(done) {
return this.duplicator.duplicate(
this.owner,
this.old_project_id,
@@ -220,7 +220,7 @@ describe('ProjectEditorHandler', function() {
)
})
return it('should include invites', function() {
it('should include invites', function() {
should.exist(this.result.invites)
return this.result.invites.should.deep.equal(this.invites)
})
@@ -248,7 +248,7 @@ describe('ProjectEditorHandler', function() {
return result.deletedByExternalDataSource.should.equal(false)
})
return it('should set the deletedByExternalDataSource flag to true when it is true', function() {
it('should set the deletedByExternalDataSource flag to true when it is true', function() {
this.project.deletedByExternalDataSource = true
const result = this.handler.buildProjectModelView(
this.project,
@@ -260,7 +260,7 @@ describe('ProjectEditorHandler', function() {
})
})
return describe('features', function() {
describe('features', function() {
beforeEach(function() {
this.owner.features = {
versioning: true,
@@ -276,7 +276,7 @@ describe('ProjectEditorHandler', function() {
))
})
return it('should copy the owner features to the project', function() {
it('should copy the owner features to the project', function() {
this.result.features.versioning.should.equal(
this.owner.features.versioning
)
@@ -293,7 +293,7 @@ describe('ProjectEditorHandler', function() {
})
})
return describe('buildOwnerAndMembersViews', function() {
describe('buildOwnerAndMembersViews', function() {
beforeEach(function() {
this.owner.features = {
versioning: true,
@@ -329,7 +329,7 @@ describe('ProjectEditorHandler', function() {
)
})
return describe('when there is no owner', function() {
describe('when there is no owner', function() {
beforeEach(function() {
// remove the owner from members list
this.membersWithoutOwner = this.members.filter(
@@ -353,7 +353,7 @@ describe('ProjectEditorHandler', function() {
return expect(this.result.owner).to.equal(null)
})
return it('should not extract the ownerFeatures from the owner object', function() {
it('should not extract the ownerFeatures from the owner object', function() {
return expect(this.result.ownerFeatures).to.equal(null)
})
})
@@ -149,7 +149,7 @@ describe('ProjectEntityHandler', function() {
.should.equal(true)
})
return it('should call the callback with the docs with the lines and rev included', function() {
it('should call the callback with the docs with the lines and rev included', function() {
return this.callback
.calledWith(null, {
'/doc1': {
@@ -175,7 +175,7 @@ describe('ProjectEntityHandler', function() {
return this.ProjectEntityHandler.getAllFiles(project_id, this.callback)
})
return it('should call the callback with the files', function() {
it('should call the callback with the files', function() {
return this.callback
.calledWith(null, {
'/file1': this.file1,
@@ -206,7 +206,7 @@ describe('ProjectEntityHandler', function() {
)
})
return it('should call the callback with the path for each doc_id', function() {
it('should call the callback with the path for each doc_id', function() {
this.expected = {}
this.expected[this.doc1._id] = `/${this.doc1.name}`
this.expected[this.doc2._id] = `/folder1/${this.doc2.name}`
@@ -229,7 +229,7 @@ describe('ProjectEntityHandler', function() {
.should.equal(true)
})
return it('should call the callback with the folders', function() {
it('should call the callback with the folders', function() {
return this.callback
.calledWith(null, {
'/': this.project.rootFolder[0],
@@ -239,7 +239,7 @@ describe('ProjectEntityHandler', function() {
})
})
return describe('_getAllFoldersFromProject', function() {
describe('_getAllFoldersFromProject', function() {
beforeEach(function() {
this.callback = sinon.stub()
return this.ProjectEntityHandler._getAllFoldersFromProject(
@@ -248,7 +248,7 @@ describe('ProjectEntityHandler', function() {
)
})
return it('should call the callback with the folders', function() {
it('should call the callback with the folders', function() {
return this.callback
.calledWith(null, {
'/': this.project.rootFolder[0],
@@ -334,7 +334,7 @@ describe('ProjectEntityHandler', function() {
})()
})
return it('should flush each file to the TPDS', function() {
it('should flush each file to the TPDS', function() {
return (() => {
const result = []
for (let path in this.files) {
@@ -356,7 +356,7 @@ describe('ProjectEntityHandler', function() {
})
})
return describe('getDoc', function() {
describe('getDoc', function() {
beforeEach(function() {
this.lines = ['mock', 'doc', 'lines']
this.rev = 5
@@ -375,7 +375,7 @@ describe('ProjectEntityHandler', function() {
.should.equal(true)
})
return it('should call the callback with the lines, version and rev', function() {
it('should call the callback with the lines, version and rev', function() {
return this.callback
.calledWith(null, this.lines, this.rev, this.version, this.ranges)
.should.equal(true)
@@ -105,7 +105,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('puts the element in mongo', function() {
it('puts the element in mongo', function() {
return this.subject._putElement
.calledWith(this.project, folder_id, this.doc, 'doc', this.callback)
.should.equal(true)
@@ -142,7 +142,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('puts the element in mongo', function() {
it('puts the element in mongo', function() {
return this.subject._putElement
.calledWith(this.project, folder_id, this.file, 'file', this.callback)
.should.equal(true)
@@ -229,7 +229,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback
.calledWith(null, this.file, this.project, this.path, this.newProject)
.should.equal(true)
@@ -361,7 +361,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
)
})
return it('should use a case-sensitive match if exactCaseMatch option is set', function(done) {
it('should use a case-sensitive match if exactCaseMatch option is set', function(done) {
const path = '/differentFolder/'
return this.subject.mkdirp(
project_id,
@@ -472,7 +472,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
const changes = {
oldDocs: this.oldDocs,
newDocs: this.newDocs,
@@ -565,7 +565,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
)
})
return it('calls the callback with an error', function() {
it('calls the callback with an error', function() {
return this.callback.calledWith(new Error()).should.equal(true)
})
})
@@ -612,7 +612,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callbck', function() {
it('calls the callbck', function() {
return this.callback
.calledWith(null, this.doc, this.path, this.project)
.should.equal(true)
@@ -701,7 +701,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
const changes = {
oldDocs: this.oldDocs,
newDocs: this.newDocs,
@@ -765,7 +765,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
const folderMatcher = sinon.match(folder => {
return folder.name === this.folderName
})
@@ -807,7 +807,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.calledWith(null, this.project).should.equal(true)
})
})
@@ -873,7 +873,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
return expect(this.subject._countElements(this.project)).to.equal(23)
})
return it('should deal with null fileRefs', function() {
it('should deal with null fileRefs', function() {
this.project.rootFolder[0].folders[0].folders[0].fileRefs = undefined
return expect(this.subject._countElements(this.project)).to.equal(23)
})
@@ -905,7 +905,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.yields(null, this.project))
})
return describe('updating the project', function() {
describe('updating the project', function() {
it('should use the correct mongo path', function(done) {
return this.subject._putElement(
this.project,
@@ -1108,7 +1108,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
)
})
return it('should error if a folder already exists with the same name', function(done) {
it('should error if a folder already exists with the same name', function(done) {
const doc = {
_id: ObjectId(),
name: 'another-folder'
@@ -1169,7 +1169,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
)
})
return it('returns nothing if name is valid', function() {
it('returns nothing if name is valid', function() {
return this.subject._checkValidElementName(
this.folder,
'unique_name',
@@ -1205,7 +1205,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
)
})
return it('returns an error if trying to move a folder inside itself', function() {
it('returns an error if trying to move a folder inside itself', function() {
const folder = { name: 'folder_name' }
return this.subject._checkValidMove(
this.project,
@@ -1224,7 +1224,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
})
})
return describe('_insertDeletedDocReference', function() {
describe('_insertDeletedDocReference', function() {
beforeEach(function() {
this.doc = {
_id: ObjectId(),
@@ -1258,7 +1258,7 @@ describe('ProjectEntityMongoUpdateHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -186,7 +186,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should should send the change in project structure to the doc updater', function() {
it('should should send the change in project structure to the doc updater', function() {
const changesMatcher = sinon.match(changes => {
const { newFiles } = changes
if (newFiles.length !== 1) {
@@ -244,7 +244,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should put file into folder by calling put element, with the linkedFileData and hash', function() {
it('should put file into folder by calling put element, with the linkedFileData and hash', function() {
return this.ProjectEntityMongoUpdateHandler._putElement
.calledWithMatch(
this.project,
@@ -348,7 +348,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -378,7 +378,7 @@ describe('ProjectEntityUpdateHandler', function() {
return this.TpdsUpdateSender.addDoc.called.should.equal(false)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -425,7 +425,7 @@ describe('ProjectEntityUpdateHandler', function() {
return this.TpdsUpdateSender.addDoc.called.should.equal(false)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -458,14 +458,14 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should return a not found error', function() {
it('should return a not found error', function() {
return this.callback
.calledWith(new Errors.NotFoundError())
.should.equal(true)
})
})
return describe('when the project is not found', function() {
describe('when the project is not found', function() {
beforeEach(function() {
this.ProjectGetter.getProjectWithoutDocLines = sinon.stub().yields()
return this.ProjectEntityUpdateHandler.updateDocLines(
@@ -480,7 +480,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('should return a not found error', function() {
it('should return a not found error', function() {
return this.callback
.calledWith(new Errors.NotFoundError())
.should.equal(true)
@@ -541,7 +541,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('sends the change in project structure to the doc updater', function() {
it('sends the change in project structure to the doc updater', function() {
const newDocs = [
{
doc: this.newDoc,
@@ -558,7 +558,7 @@ describe('ProjectEntityUpdateHandler', function() {
})
})
return describe('adding a doc with an invalid name', function() {
describe('adding a doc with an invalid name', function() {
beforeEach(function() {
this.path = '/path/to/doc'
@@ -573,7 +573,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -641,7 +641,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('sends the change in project structure to the doc updater', function() {
it('sends the change in project structure to the doc updater', function() {
const newFiles = [
{
file: this.newFile,
@@ -658,7 +658,7 @@ describe('ProjectEntityUpdateHandler', function() {
})
})
return describe('adding a file with an invalid name', function() {
describe('adding a file with an invalid name', function() {
beforeEach(function() {
this.path = '/path/to/file'
@@ -683,7 +683,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -763,7 +763,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('updates the project structure in the doc updater', function() {
it('updates the project structure in the doc updater', function() {
const oldFiles = [
{
file: this.oldFile,
@@ -802,7 +802,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Error)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -851,7 +851,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('returns the doc', function() {
it('returns the doc', function() {
return this.callback.calledWith(null, this.existingDoc, false)
})
})
@@ -895,12 +895,12 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('returns the doc', function() {
it('returns the doc', function() {
return this.callback.calledWith(null, this.newDoc, true)
})
})
return describe('upserting a new doc with an invalid name', function() {
describe('upserting a new doc with an invalid name', function() {
beforeEach(function() {
this.folder = { _id: folder_id, docs: [] }
this.newDoc = { _id: doc_id }
@@ -920,7 +920,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -948,7 +948,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Error)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -986,7 +986,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('returns the file', function() {
it('returns the file', function() {
return this.callback.calledWith(null, this.existingFile, false)
})
})
@@ -1030,12 +1030,12 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('returns the file', function() {
it('returns the file', function() {
return this.callback.calledWith(null, this.newFile, true)
})
})
return describe('upserting a new file with an invalid name', function() {
describe('upserting a new file with an invalid name', function() {
beforeEach(function() {
this.folder = { _id: folder_id, fileRefs: [] }
this.newFile = { _id: file_id }
@@ -1055,7 +1055,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -1106,7 +1106,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback
.calledWith(
null,
@@ -1143,13 +1143,13 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
})
return describe('upserting a doc with an invalid name', function() {
describe('upserting a doc with an invalid name', function() {
beforeEach(function() {
this.path = '/folder/*doc.tex'
this.newFolders = ['mock-a', 'mock-b']
@@ -1173,7 +1173,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -1227,7 +1227,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback
.calledWith(
null,
@@ -1265,13 +1265,13 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
})
return describe('upserting a file with an invalid name', function() {
describe('upserting a file with an invalid name', function() {
beforeEach(function() {
this.path = '/folder/*file.png'
this.newFolders = ['mock-a', 'mock-b']
@@ -1295,7 +1295,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -1358,7 +1358,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('retuns the entity_id', function() {
it('retuns the entity_id', function() {
return this.callback.calledWith(null, doc_id).should.equal(true)
})
})
@@ -1388,14 +1388,14 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('deletes the entity', function() {
it('deletes the entity', function() {
return this.ProjectEntityUpdateHandler.deleteEntity.withoutLock
.calledWith(project_id, this.doc._id, 'doc', userId, this.callback)
.should.equal(true)
})
})
return describe('when the entity does not exist', function() {
describe('when the entity does not exist', function() {
beforeEach(function() {
this.ProjectLocator.findElementByPath = sinon.stub().yields()
this.path = '/doc.tex'
@@ -1407,7 +1407,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
return this.callback
.calledWith(new Errors.NotFoundError())
.should.equal(true)
@@ -1426,7 +1426,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('calls ProjectEntityMongoUpdateHandler', function() {
it('calls ProjectEntityMongoUpdateHandler', function() {
return this.ProjectEntityMongoUpdateHandler.mkdirp
.calledWith(project_id, this.docPath)
.should.equal(true)
@@ -1444,7 +1444,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('calls ProjectEntityMongoUpdateHandler', function() {
it('calls ProjectEntityMongoUpdateHandler', function() {
return this.ProjectEntityMongoUpdateHandler.mkdirp
.calledWith(project_id, this.docPath, { exactCaseMatch: true })
.should.equal(true)
@@ -1465,14 +1465,14 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('calls ProjectEntityMongoUpdateHandler', function() {
it('calls ProjectEntityMongoUpdateHandler', function() {
return this.ProjectEntityMongoUpdateHandler.addFolder
.calledWith(project_id, this.parentFolder_id, this.folderName)
.should.equal(true)
})
})
return describe('adding a folder with an invalid name', function() {
describe('adding a folder with an invalid name', function() {
beforeEach(function() {
this.parentFolder_id = '123asdf'
this.folderName = '*new-folder'
@@ -1485,7 +1485,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -1540,7 +1540,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('sends the changes in project structure to the doc updater', function() {
it('sends the changes in project structure to the doc updater', function() {
return this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(
project_id,
@@ -1603,7 +1603,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('sends the changes in project structure to the doc updater', function() {
it('sends the changes in project structure to the doc updater', function() {
return this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(
project_id,
@@ -1616,7 +1616,7 @@ describe('ProjectEntityUpdateHandler', function() {
})
})
return describe('renaming an entity to an invalid name', function() {
describe('renaming an entity to an invalid name', function() {
beforeEach(function() {
this.project_name = 'project name'
this.startPath = '/folder/a.tex'
@@ -1647,7 +1647,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('returns an error', function() {
it('returns an error', function() {
const errorMatcher = sinon.match.instanceOf(Errors.InvalidNameError)
return this.callback.calledWithMatch(errorMatcher).should.equal(true)
})
@@ -1665,7 +1665,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
const error = new Errors.ProjectHistoryDisabledError(
`project history not enabled for ${project_id}`
)
@@ -1684,7 +1684,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
const error = new Errors.ProjectHistoryDisabledError(
`project history not enabled for ${project_id}`
)
@@ -1692,7 +1692,7 @@ describe('ProjectEntityUpdateHandler', function() {
})
})
return describe('a project with project-history enabled', function() {
describe('a project with project-history enabled', function() {
beforeEach(function() {
this.ProjectGetter.getProject = sinon.stub().yields(null, this.project)
const docs = [
@@ -1755,7 +1755,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('calls the callback', function() {
it('calls the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -1804,7 +1804,7 @@ describe('ProjectEntityUpdateHandler', function() {
return this.DocumentUpdaterHandler.deleteDoc.called.should.equal(false)
})
return it('should should send the update to the doc updater', function() {
it('should should send the update to the doc updater', function() {
const oldFiles = [{ file: this.entity, path: this.path }]
return this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(project_id, projectHistoryId, userId, {
@@ -1838,7 +1838,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should should send the update to the doc updater', function() {
it('should should send the update to the doc updater', function() {
const oldDocs = [{ doc: this.entity, path: this.path }]
return this.DocumentUpdaterHandler.updateProjectStructure
.calledWith(project_id, projectHistoryId, userId, {
@@ -1849,7 +1849,7 @@ describe('ProjectEntityUpdateHandler', function() {
})
})
return describe('a folder', function() {
describe('a folder', function() {
beforeEach(function(done) {
this.folder = {
folders: [
@@ -1909,7 +1909,7 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should should send one update to the doc updater for all docs and files', function() {
it('should should send one update to the doc updater for all docs and files', function() {
const oldFiles = [
{ file: this.file2, path: '/folder/file-name-2' },
{ file: this.file1, path: '/folder/subfolder/file-name-1' }
@@ -1929,7 +1929,7 @@ describe('ProjectEntityUpdateHandler', function() {
})
})
return describe('_cleanUpDoc', function() {
describe('_cleanUpDoc', function() {
beforeEach(function() {
this.doc = {
_id: ObjectId(),
@@ -1982,12 +1982,12 @@ describe('ProjectEntityUpdateHandler', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when the doc is not the root doc', function() {
describe('when the doc is not the root doc', function() {
beforeEach(function() {
this.project.rootDoc_id = ObjectId()
return this.ProjectEntityUpdateHandler._cleanUpDoc(
@@ -2005,7 +2005,7 @@ describe('ProjectEntityUpdateHandler', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -63,7 +63,7 @@ describe('ProjectGetter', function() {
return (this.ProjectGetter.getProject = sinon.stub().yields())
})
return describe('passing an id', function() {
describe('passing an id', function() {
beforeEach(function() {
return this.ProjectGetter.getProjectWithoutDocLines(
this.project_id,
@@ -94,7 +94,7 @@ describe('ProjectGetter', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -106,7 +106,7 @@ describe('ProjectGetter', function() {
return (this.ProjectGetter.getProject = sinon.stub().yields())
})
return describe('passing an id', function() {
describe('passing an id', function() {
beforeEach(function() {
return this.ProjectGetter.getProjectWithOnlyFolders(
this.project_id,
@@ -144,7 +144,7 @@ describe('ProjectGetter', function() {
.should.equal(true)
})
return it('should call the callback with the project', function() {
it('should call the callback with the project', function() {
return this.callback.called.should.equal(true)
})
})
@@ -164,7 +164,7 @@ describe('ProjectGetter', function() {
return this.ProjectGetter.getProject(this.project_id, this.callback)
})
return it('should call find with the project id', function() {
it('should call find with the project id', function() {
expect(this.db.projects.find.callCount).to.equal(1)
return expect(this.db.projects.find.lastCall.args[0]).to.deep.equal({
_id: ObjectId(this.project_id)
@@ -172,19 +172,19 @@ describe('ProjectGetter', function() {
})
})
return describe('without project id', function() {
describe('without project id', function() {
beforeEach(function() {
return this.ProjectGetter.getProject(null, this.callback)
})
return it('should callback with error', function() {
it('should callback with error', function() {
expect(this.db.projects.find.callCount).to.equal(0)
return expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
})
})
return describe('with projection', function() {
describe('with projection', function() {
beforeEach(function() {
return (this.projection = { _id: 1 })
})
@@ -198,7 +198,7 @@ describe('ProjectGetter', function() {
)
})
return it('should call find with the project id', function() {
it('should call find with the project id', function() {
expect(this.db.projects.find.callCount).to.equal(1)
expect(this.db.projects.find.lastCall.args[0]).to.deep.equal({
_id: ObjectId(this.project_id)
@@ -209,12 +209,12 @@ describe('ProjectGetter', function() {
})
})
return describe('without project id', function() {
describe('without project id', function() {
beforeEach(function() {
return this.ProjectGetter.getProject(null, this.callback)
})
return it('should callback with error', function() {
it('should callback with error', function() {
expect(this.db.projects.find.callCount).to.equal(0)
return expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
@@ -239,7 +239,7 @@ describe('ProjectGetter', function() {
)
})
return it('should call find with the project id', function() {
it('should call find with the project id', function() {
expect(this.db.projects.find.callCount).to.equal(1)
return expect(this.db.projects.find.lastCall.args[0]).to.deep.equal({
_id: ObjectId(this.project_id)
@@ -247,19 +247,19 @@ describe('ProjectGetter', function() {
})
})
return describe('without project id', function() {
describe('without project id', function() {
beforeEach(function() {
return this.ProjectGetter.getProjectWithoutLock(null, this.callback)
})
return it('should callback with error', function() {
it('should callback with error', function() {
expect(this.db.projects.find.callCount).to.equal(0)
return expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
})
})
return describe('with projection', function() {
describe('with projection', function() {
beforeEach(function() {
return (this.projection = { _id: 1 })
})
@@ -273,7 +273,7 @@ describe('ProjectGetter', function() {
)
})
return it('should call find with the project id', function() {
it('should call find with the project id', function() {
expect(this.db.projects.find.callCount).to.equal(1)
expect(this.db.projects.find.lastCall.args[0]).to.deep.equal({
_id: ObjectId(this.project_id)
@@ -284,12 +284,12 @@ describe('ProjectGetter', function() {
})
})
return describe('without project id', function() {
describe('without project id', function() {
beforeEach(function() {
return this.ProjectGetter.getProjectWithoutLock(null, this.callback)
})
return it('should callback with error', function() {
it('should callback with error', function() {
expect(this.db.projects.find.callCount).to.equal(0)
return expect(this.callback.lastCall.args[0]).to.be.instanceOf(Error)
})
@@ -320,7 +320,7 @@ describe('ProjectGetter', function() {
)
})
return it('should call the callback with all the projects', function() {
it('should call the callback with all the projects', function() {
return this.callback
.calledWith(null, {
owned: ['mock-owned-projects'],
@@ -333,7 +333,7 @@ describe('ProjectGetter', function() {
})
})
return describe('getProjectIdByReadAndWriteToken', function() {
describe('getProjectIdByReadAndWriteToken', function() {
describe('when project find returns project', function() {
this.beforeEach(function() {
this.Project.findOne = sinon.stub().yields(null, { _id: 'project-id' })
@@ -349,7 +349,7 @@ describe('ProjectGetter', function() {
.should.equal(true)
})
return it('should callback with project id', function() {
it('should callback with project id', function() {
return this.callback.calledWith(null, 'project-id').should.equal(true)
})
})
@@ -363,12 +363,12 @@ describe('ProjectGetter', function() {
)
})
return it('should callback empty', function() {
it('should callback empty', function() {
return expect(this.callback.firstCall.args.length).to.equal(0)
})
})
return describe('when project find returns error', function() {
describe('when project find returns error', function() {
this.beforeEach(function() {
this.Project.findOne = sinon.stub().yields('error')
return this.ProjectGetter.getProjectIdByReadAndWriteToken(
@@ -377,7 +377,7 @@ describe('ProjectGetter', function() {
)
})
return it('should callback with error', function() {
it('should callback with error', function() {
return this.callback.calledWith('error').should.equal(true)
})
})
@@ -22,7 +22,7 @@ describe('ProjectHelper', function() {
return (this.ProjectHelper = SandboxedModule.require(modulePath))
})
return describe('compilerFromV1Engine', function() {
describe('compilerFromV1Engine', function() {
it('returns the correct engine for latex_dvipdf', function() {
return expect(
this.ProjectHelper.compilerFromV1Engine('latex_dvipdf')
@@ -41,7 +41,7 @@ describe('ProjectHelper', function() {
).to.equal('xelatex')
})
return it('returns the correct engine for lualatex', function() {
it('returns the correct engine for lualatex', function() {
return expect(
this.ProjectHelper.compilerFromV1Engine('lualatex')
).to.equal('lualatex')
@@ -63,7 +63,7 @@ describe('ProjectHistoryHandler', function() {
}))
})
return describe('starting history for an existing project', function() {
describe('starting history for an existing project', function() {
beforeEach(function() {
this.newHistoryId = 123456789
this.HistoryManager.initializeProject = sinon
@@ -119,12 +119,12 @@ describe('ProjectHistoryHandler', function() {
.should.equal(true)
})
return it('should call the callback without an error', function() {
it('should call the callback without an error', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when the history already exists', function() {
describe('when the history already exists', function() {
beforeEach(function() {
this.project.overleaf = { history: { id: 1234 } }
this.ProjectDetailsHandler.getDetails = sinon
@@ -162,7 +162,7 @@ describe('ProjectHistoryHandler', function() {
return this.HistoryManager.flushProject.called.should.equal(false)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.calledWith().should.equal(true)
})
})
@@ -110,7 +110,7 @@ describe('ProjectLocator', function() {
)
})
return it('should give error if element could not be found', function(done) {
it('should give error if element could not be found', function(done) {
return this.locator.findElement(
{ project_id: project._id, element_id: 'ddsd432nj42', type: 'docs' },
function(err, foundElement, path, parentFolder) {
@@ -147,7 +147,7 @@ describe('ProjectLocator', function() {
)
})
return it('when deeply nested', function(done) {
it('when deeply nested', function(done) {
return this.locator.findElement(
{
project_id: project._id,
@@ -183,7 +183,7 @@ describe('ProjectLocator', function() {
)
})
return it('when deeply nested', function(done) {
it('when deeply nested', function(done) {
return this.locator.findElement(
{
project_id: project._id,
@@ -216,7 +216,7 @@ describe('ProjectLocator', function() {
)
})
return it('should convert file to fileRefs', function(done) {
it('should convert file to fileRefs', function(done) {
return this.locator.findElement(
{ project_id: project._id, element_id: file1._id, type: 'fileRefs' },
function(err, foundElement, path, parentFolder) {
@@ -241,7 +241,7 @@ describe('ProjectLocator', function() {
_id: '1234566',
rootFolder: [rootFolder2]
}
return it('should find doc in project', function(done) {
it('should find doc in project', function(done) {
return this.locator.findElement(
{ project: project2, element_id: doc3._id, type: 'docs' },
function(err, foundElement, path, parentFolder) {
@@ -282,7 +282,7 @@ describe('ProjectLocator', function() {
})
})
return it('should return null when the rootDoc_id no longer exists', function(done) {
it('should return null when the rootDoc_id no longer exists', function(done) {
project.rootDoc_id = 'doesntexist'
return this.locator.findRootDoc(project, function(err, doc) {
assert(err == null)
@@ -462,7 +462,7 @@ describe('ProjectLocator', function() {
)
}) // mocha will throw exception if done called multiple times
return it('should not call the callback more than once when the path is longer than 1 level below the duplicate level', function(done) {
it('should not call the callback more than once when the path is longer than 1 level below the duplicate level', function(done) {
const path = `${this.duplicateFolder.name}/1/main.tex`
return this.locator.findElementByPath(
{ project: this.project, path },
@@ -484,7 +484,7 @@ describe('ProjectLocator', function() {
})
})
return it('should not crash with a null', function(done) {
it('should not crash with a null', function(done) {
const path = '/other.tex'
return this.locator.findElementByPath(
{ project: this.project, path },
@@ -501,7 +501,7 @@ describe('ProjectLocator', function() {
return (this.ProjectGetter = { getProject: sinon.stub().callsArg(2) })
})
return it('should not crash with a null', function(done) {
it('should not crash with a null', function(done) {
const path = '/other.tex'
return this.locator.findElementByPath(
{ project_id: project._id, path },
@@ -513,7 +513,7 @@ describe('ProjectLocator', function() {
})
})
return describe('with a project_id', () =>
describe('with a project_id', () =>
it('should take a doc path and return the element for a root level document', function(done) {
const path = `${doc1.name}`
return this.locator.findElementByPath(
@@ -530,7 +530,7 @@ describe('ProjectLocator', function() {
}))
})
return describe('findUsersProjectByName finding a project by user_id and project name', function() {
describe('findUsersProjectByName finding a project by user_id and project name', function() {
it('should return the project from an array case insenstive', function(done) {
const user_id = '123jojoidns'
const stubbedProject = { name: 'findThis' }
@@ -581,7 +581,7 @@ describe('ProjectLocator', function() {
)
})
return it('should search collab projects as well', function(done) {
it('should search collab projects as well', function(done) {
const user_id = '123jojoidns'
const stubbedProject = { name: 'findThis' }
const projects = {
@@ -64,7 +64,7 @@ describe('ProjectOptionsHandler', function() {
return this.projectModel.update.args[0][3]()
})
return it('should not perform and update on mongo if it is not a reconised compiler', function(done) {
it('should not perform and update on mongo if it is not a reconised compiler', function(done) {
return this.handler.setCompiler(project_id, 'something', err => {
this.projectModel.update.called.should.equal(false)
return done()
@@ -83,7 +83,7 @@ describe('ProjectOptionsHandler', function() {
return this.projectModel.update.args[0][3]()
})
return it('should not perform and update on mongo if it is not a reconised compiler', function(done) {
it('should not perform and update on mongo if it is not a reconised compiler', function(done) {
return this.handler.setImageName(project_id, 'something', err => {
this.projectModel.update.called.should.equal(false)
return done()
@@ -113,7 +113,7 @@ describe('ProjectOptionsHandler', function() {
)
})
return it('should perform and update on mongo if the language is blank (means turn it off)', function(done) {
it('should perform and update on mongo if the language is blank (means turn it off)', function(done) {
this.handler.setSpellCheckLanguage(project_id, '', err => {
this.projectModel.update.called.should.equal(true)
return done()
@@ -140,7 +140,7 @@ describe('ProjectOptionsHandler', function() {
})
})
return it('should not perform and update on mongo if brand variation is an empty string', function(done) {
it('should not perform and update on mongo if brand variation is an empty string', function(done) {
return this.handler.setBrandVariationId(project_id, '', err => {
this.projectModel.update.called.should.equal(false)
return done()
@@ -148,7 +148,7 @@ describe('ProjectOptionsHandler', function() {
})
})
return describe('unsetting the brandVariationId', () =>
describe('unsetting the brandVariationId', () =>
it('should perform and update on mongo', function(done) {
this.handler.unsetBrandVariationId(project_id, err => {
const args = this.projectModel.update.args[0]
@@ -100,7 +100,7 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should set the root doc to the doc containing a documentclass', function() {
it('should set the root doc to the doc containing a documentclass', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(this.project_id, 'doc-id-2')
.should.equal(true)
@@ -131,14 +131,14 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should set the root doc to the doc containing a documentclass', function() {
it('should set the root doc to the doc containing a documentclass', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(this.project_id, 'doc-id-2')
.should.equal(true)
})
})
return describe('when there is no suitable root doc', function() {
describe('when there is no suitable root doc', function() {
beforeEach(function(done) {
this.docs = {
'/chapter1.tex': {
@@ -162,7 +162,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should not set the root doc to the doc containing a documentclass', function() {
it('should not set the root doc to the doc containing a documentclass', function() {
return this.ProjectEntityUpdateHandler.setRootDoc.called.should.equal(
false
)
@@ -220,7 +220,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('processes smaller files first', function(done) {
it('processes smaller files first', function(done) {
this.fs.stat.withArgs('/foo/c.tex').callsArgWith(1, null, { size: 1 })
return this.ProjectRootDocManager.findRootDocFileFromDirectory(
'/foo',
@@ -258,7 +258,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('processes main.text first and stops processing when it finds the content', function(done) {
it('processes main.text first and stops processing when it finds the content', function(done) {
return this.ProjectRootDocManager.findRootDocFileFromDirectory(
'/foo',
() => {
@@ -289,7 +289,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('processes main.text first and stops processing when it finds the content', function(done) {
it('processes main.text first and stops processing when it finds the content', function(done) {
return this.ProjectRootDocManager.findRootDocFileFromDirectory(
'/foo',
() => {
@@ -315,7 +315,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('processes all the files', function(done) {
it('processes all the files', function(done) {
return this.ProjectRootDocManager.findRootDocFileFromDirectory(
'/foo',
() => {
@@ -328,14 +328,14 @@ describe('ProjectRootDocManager', function() {
})
})
return describe('when there is an error reading a file', function() {
describe('when there is an error reading a file', function() {
beforeEach(function() {
return this.fs.readFile
.withArgs('/foo/a.tex')
.callsArgWith(2, new Error('something went wrong'))
})
return it('returns an error', function(done) {
it('returns an error', function(done) {
return this.ProjectRootDocManager.findRootDocFileFromDirectory(
'/foo',
(error, path, content) => {
@@ -377,7 +377,7 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should set the root doc to main.tex', function() {
it('should set the root doc to main.tex', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(this.project_id, 'doc-id-2')
.should.equal(true)
@@ -405,7 +405,7 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should set the root doc to main.tex', function() {
it('should set the root doc to main.tex', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(this.project_id, 'doc-id-2')
.should.equal(true)
@@ -433,7 +433,7 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should set the root doc using the basename', function() {
it('should set the root doc using the basename', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(this.project_id, 'doc-id-3')
.should.equal(true)
@@ -461,14 +461,14 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should set the root doc to main.tex', function() {
it('should set the root doc to main.tex', function() {
return this.ProjectEntityUpdateHandler.setRootDoc
.calledWith(this.project_id, 'doc-id-2')
.should.equal(true)
})
})
return describe('when there is no suitable root doc', function() {
describe('when there is no suitable root doc', function() {
beforeEach(function(done) {
this.ProjectEntityHandler.getAllDocPathsFromProjectById = sinon
.stub()
@@ -483,7 +483,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should not set the root doc', function() {
it('should not set the root doc', function() {
return this.ProjectEntityUpdateHandler.setRootDoc.called.should.equal(
false
)
@@ -523,7 +523,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -548,12 +548,12 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when the project does not exist', function() {
describe('when the project does not exist', function() {
beforeEach(function() {
this.ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, null)
return this.ProjectRootDocManager.ensureRootDocumentIsSet(
@@ -562,7 +562,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback
.calledWith(new Error('project not found'))
.should.equal(true)
@@ -570,7 +570,7 @@ describe('ProjectRootDocManager', function() {
})
})
return describe('ensureRootDocumentIsValid', function() {
describe('ensureRootDocumentIsValid', function() {
beforeEach(function() {
this.project = {}
this.ProjectGetter.getProject = sinon
@@ -607,12 +607,12 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when the root doc is not valid', function() {
describe('when the root doc is not valid', function() {
beforeEach(function() {
this.project.rootDoc_id = 'bogus-doc-id'
return this.ProjectRootDocManager.ensureRootDocumentIsValid(
@@ -639,7 +639,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -665,12 +665,12 @@ describe('ProjectRootDocManager', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when the project does not exist', function() {
describe('when the project does not exist', function() {
beforeEach(function() {
this.ProjectGetter.getProject = sinon.stub().callsArgWith(2, null, null)
return this.ProjectRootDocManager.ensureRootDocumentIsSet(
@@ -679,7 +679,7 @@ describe('ProjectRootDocManager', function() {
)
})
return it('should call the callback with an error', function() {
it('should call the callback with an error', function() {
return this.callback
.calledWith(new Error('project not found'))
.should.equal(true)
@@ -69,7 +69,7 @@ describe('ProjectUpdateHandler', function() {
)
})
return it('should set smart fallbacks', function(done) {
it('should set smart fallbacks', function(done) {
return this.handler.markAsUpdated(this.project_id, null, null, err => {
sinon.assert.calledWithMatch(
this.ProjectModel.update,
@@ -111,7 +111,7 @@ describe('ProjectUpdateHandler', function() {
})
}))
return describe('markAsActive', () =>
describe('markAsActive', () =>
it('should send an update to mongo', function(done) {
const project_id = 'project_id'
return this.handler.markAsActive(project_id, err => {
@@ -108,7 +108,7 @@ describe('SafePath', function() {
// result = @SafePath.isCleanFilename 'hello.'
// result.should.equal false
return it('should not accept \\', function() {
it('should not accept \\', function() {
const result = this.SafePath.isCleanFilename('foo\\bar')
return result.should.equal(false)
})
@@ -190,7 +190,7 @@ describe('SafePath', function() {
return result.should.equal(false)
})
return it('should not accept javascript property names resulting from substitutions', function() {
it('should not accept javascript property names resulting from substitutions', function() {
const result = this.SafePath.isCleanPath(' proto ')
return result.should.equal(false)
})
@@ -208,13 +208,13 @@ describe('SafePath', function() {
return result.should.equal(false)
})
return it('should not accept an empty path', function() {
it('should not accept an empty path', function() {
const result = this.SafePath.isAllowedLength('')
return result.should.equal(false)
})
})
return describe('clean', function() {
describe('clean', function() {
it('should not modify a valid filename', function() {
const result = this.SafePath.clean('main.tex')
return result.should.equal('main.tex')
@@ -260,7 +260,7 @@ describe('SafePath', function() {
return result.should.equal('@prototype')
})
return it('should prefix javascript property names in the prototype with @', function() {
it('should prefix javascript property names in the prototype with @', function() {
const result = this.SafePath.clean('hasOwnProperty')
return result.should.equal('@hasOwnProperty')
})
@@ -57,7 +57,7 @@ describe('PublishersGetter', function() {
return (this.userId = '12345abcde')
})
return describe('getManagedPublishers', () =>
describe('getManagedPublishers', () =>
it('fetches v1 data before returning publisher list', function(done) {
return this.PublishersGetter.getManagedPublishers(this.userId, function(
error,
@@ -46,7 +46,7 @@ describe('ReferalAllocator', function() {
.callsArgWith(1, null, { _id: this.user_id }))
})
return describe('allocate', function() {
describe('allocate', function() {
describe('when the referal was a bonus referal', function() {
beforeEach(function() {
this.referal_source = 'bonus'
@@ -89,7 +89,7 @@ describe('ReferalAllocator', function() {
.should.equal(true)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -122,12 +122,12 @@ describe('ReferalAllocator', function() {
return this.FeaturesUpdater.refreshFeatures.called.should.equal(false)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
return describe('when the referal is not a bonus referal', function() {
describe('when the referal is not a bonus referal', function() {
beforeEach(function() {
this.referal_source = 'public_share'
return this.ReferalAllocator.allocate(
@@ -153,7 +153,7 @@ describe('ReferalAllocator', function() {
return this.FeaturesUpdater.refreshFeatures.called.should.equal(false)
})
return it('should call the callback', function() {
it('should call the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -141,7 +141,7 @@ describe('Referal connect middle wear', function() {
})
})
return it('should map the collaborator invite into the session', function(done) {
it('should map the collaborator invite into the session', function(done) {
const req = {
query: { rs: 'ci' },
session: {}
@@ -65,14 +65,14 @@ describe('ReferalFeatures', function() {
.should.equal(true)
})
return it('should call the callback with the features', function() {
it('should call the callback with the features', function() {
return this.callback
.calledWith(null, this.Settings.bonus_features[3])
.should.equal(true)
})
})
return describe('when the user is not at a bonus level', function() {
describe('when the user is not at a bonus level', function() {
beforeEach(function() {
this.refered_user_count = 0
this.Settings.bonus_features = {
@@ -94,7 +94,7 @@ describe('ReferalFeatures', function() {
.should.equal(true)
})
return it('should call the callback with no features', function() {
it('should call the callback with no features', function() {
return this.callback.calledWith(null, {}).should.equal(true)
})
})
@@ -37,7 +37,7 @@ describe('Referal handler', function() {
return (this.user_id = '12313')
})
return describe('getting refered user_ids', function() {
describe('getting refered user_ids', function() {
it('should get the user from mongo and return the refered users array', function(done) {
const user = {
refered_users: ['1234', '312312', '3213129'],
@@ -98,7 +98,7 @@ describe('Referal handler', function() {
})
})
return it('should return the count if it differs from the array length', function(done) {
it('should return the count if it differs from the array length', function(done) {
const user = {
refered_users: ['1234', '312312', '3213129'],
refered_user_count: 5
@@ -123,7 +123,7 @@ describe('ReferencesController', function() {
})
})
return it('should still return data', function(done) {
it('should still return data', function(done) {
return this.call(() => {
this.res.json.callCount.should.equal(1)
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
@@ -132,7 +132,7 @@ describe('ReferencesController', function() {
})
})
return describe('when shouldBroadcast is false', function() {
describe('when shouldBroadcast is false', function() {
beforeEach(function() {
this.ReferencesHandler.index.callsArgWith(
2,
@@ -158,7 +158,7 @@ describe('ReferencesController', function() {
})
})
return it('should still return data', function(done) {
it('should still return data', function(done) {
return this.call(() => {
this.res.json.callCount.should.equal(1)
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
@@ -193,7 +193,7 @@ describe('ReferencesController', function() {
})
})
return it('should send a response with an empty keys list', function(done) {
it('should send a response with an empty keys list', function(done) {
return this.call(() => {
this.res.json.called.should.equal(true)
this.res.json
@@ -204,7 +204,7 @@ describe('ReferencesController', function() {
})
})
return describe('index', function() {
describe('index', function() {
beforeEach(function() {
return (this.call = callback => {
this.controller.index(this.req, this.res)
@@ -255,7 +255,7 @@ describe('ReferencesController', function() {
})
})
return describe('when ReferencesHandler.index produces an error', function() {
describe('when ReferencesHandler.index produces an error', function() {
beforeEach(function() {
return this.ReferencesHandler.index.callsArgWith(
2,
@@ -264,7 +264,7 @@ describe('ReferencesController', function() {
)
})
return it('should produce an error response', function(done) {
it('should produce an error response', function(done) {
return this.call(() => {
this.res.sendStatus.callCount.should.equal(1)
this.res.sendStatus.calledWith(500).should.equal(true)
@@ -300,7 +300,7 @@ describe('ReferencesController', function() {
})
})
return it('should still return data', function(done) {
it('should still return data', function(done) {
return this.call(() => {
this.res.json.callCount.should.equal(1)
this.res.json.calledWith(this.fakeResponseData).should.equal(true)
@@ -322,7 +322,7 @@ describe('ReferencesController', function() {
})
})
return it('should not call ReferencesHandler.index', function(done) {
it('should not call ReferencesHandler.index', function(done) {
return this.call(() => {
this.ReferencesHandler.index.callCount.should.equal(0)
return done()
@@ -330,7 +330,7 @@ describe('ReferencesController', function() {
})
})
return describe('with invalid docIds', function() {
describe('with invalid docIds', function() {
beforeEach(function() {
return (this.req.body.docIds = 42)
})
@@ -343,7 +343,7 @@ describe('ReferencesController', function() {
})
})
return it('should not call ReferencesHandler.index', function(done) {
it('should not call ReferencesHandler.index', function(done) {
return this.call(() => {
this.ReferencesHandler.index.callCount.should.equal(0)
return done()
@@ -156,7 +156,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should return data', function(done) {
it('should return data', function(done) {
return this.call((err, data) => {
expect(data).to.not.equal(null)
expect(data).to.not.equal(undefined)
@@ -180,7 +180,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should not send request', function(done) {
it('should not send request', function(done) {
return this.call((err, data) => {
this.request.post.callCount.should.equal(0)
return done()
@@ -203,7 +203,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should not send request', function(done) {
it('should not send request', function(done) {
return this.call((err, data) => {
this.request.post.callCount.should.equal(0)
return done()
@@ -230,7 +230,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should not send request', function(done) {
it('should not send request', function(done) {
return this.call((err, data) => {
this.request.post.callCount.should.equal(0)
return done()
@@ -246,7 +246,7 @@ describe('ReferencesHandler', function() {
return this.request.post.callsArgWith(1, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, data) => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -256,7 +256,7 @@ describe('ReferencesHandler', function() {
})
})
return describe('when request responds with error status', function() {
describe('when request responds with error status', function() {
beforeEach(function() {
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
this.handler._isFullIndex.callsArgWith(1, null, false)
@@ -268,7 +268,7 @@ describe('ReferencesHandler', function() {
)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, data) => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -363,7 +363,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should not send request', function(done) {
it('should not send request', function(done) {
return this.call((err, data) => {
this.request.post.callCount.should.equal(0)
return done()
@@ -386,7 +386,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should not send request', function(done) {
it('should not send request', function(done) {
return this.call((err, data) => {
this.request.post.callCount.should.equal(0)
return done()
@@ -394,7 +394,7 @@ describe('ReferencesHandler', function() {
})
})
return describe('when flushDocToMongo produces an error', function() {
describe('when flushDocToMongo produces an error', function() {
beforeEach(function() {
this.ProjectGetter.getProject.callsArgWith(2, null, this.fakeProject)
this.handler._isFullIndex.callsArgWith(1, false)
@@ -413,7 +413,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should not send request', function(done) {
it('should not send request', function(done) {
return this.call((err, data) => {
this.request.post.callCount.should.equal(0)
return done()
@@ -445,7 +445,7 @@ describe('ReferencesHandler', function() {
return expect(result).to.deep.equal(this.expectedIds)
})
return it('should not error with a non array of folders from dirty data', function() {
it('should not error with a non array of folders from dirty data', function() {
this.fakeProject.rootFolder[0].folders[0].folders = {}
const result = this.handler._findBibDocIds(this.fakeProject)
return expect(result).to.deep.equal(this.expectedIds)
@@ -475,13 +475,13 @@ describe('ReferencesHandler', function() {
return (this.expectedIds = ['ddd', 'ghg'])
})
return it('should select the correct docIds', function() {
it('should select the correct docIds', function() {
const result = this.handler._findBibFileIds(this.fakeProject)
return expect(result).to.deep.equal(this.expectedIds)
})
})
return describe('_isFullIndex', function() {
describe('_isFullIndex', function() {
beforeEach(function() {
this.fakeProject = { owner_ref: (this.owner_ref = 'owner-ref-123') }
this.owner = {
@@ -503,7 +503,7 @@ describe('ReferencesHandler', function() {
return (this.owner.features.references = true)
})
return it('should return true', function() {
it('should return true', function() {
return this.call((err, isFullIndex) => {
expect(err).to.equal(null)
return expect(isFullIndex).to.equal(true)
@@ -516,7 +516,7 @@ describe('ReferencesHandler', function() {
return (this.owner.features.references = false)
})
return it('should return false', function() {
it('should return false', function() {
return this.call((err, isFullIndex) => {
expect(err).to.equal(null)
return expect(isFullIndex).to.equal(false)
@@ -524,7 +524,7 @@ describe('ReferencesHandler', function() {
})
})
return describe('with referencesSearch', function() {
describe('with referencesSearch', function() {
beforeEach(function() {
return (this.owner.features = {
referencesSearch: true,
@@ -532,7 +532,7 @@ describe('ReferencesHandler', function() {
})
})
return it('should return true', function() {
it('should return true', function() {
return this.call((err, isFullIndex) => {
expect(err).to.equal(null)
return expect(isFullIndex).to.equal(true)
@@ -64,7 +64,7 @@ describe('LoginRateLimiter', function() {
.callsArgWith(1, null, true))
})
return it('should call pass allow=true', function(done) {
it('should call pass allow=true', function(done) {
return this.LoginRateLimiter.processLoginRequest(
this.email,
(err, allow) => {
@@ -83,7 +83,7 @@ describe('LoginRateLimiter', function() {
.callsArgWith(1, null, false))
})
return it('should call pass allow=false', function(done) {
it('should call pass allow=false', function(done) {
return this.LoginRateLimiter.processLoginRequest(
this.email,
(err, allow) => {
@@ -95,14 +95,14 @@ describe('LoginRateLimiter', function() {
})
})
return describe('when addCount produces an error', function() {
describe('when addCount produces an error', function() {
beforeEach(function() {
return (this.RateLimiter.addCount = sinon
.stub()
.callsArgWith(1, new Error('woops')))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.LoginRateLimiter.processLoginRequest(
this.email,
(err, allow) => {
@@ -115,14 +115,14 @@ describe('LoginRateLimiter', function() {
})
})
return describe('recordSuccessfulLogin', function() {
describe('recordSuccessfulLogin', function() {
beforeEach(function() {
return (this.RateLimiter.clearRateLimit = sinon
.stub()
.callsArgWith(2, null))
})
return it('should call clearRateLimit', function(done) {
it('should call clearRateLimit', function(done) {
return this.LoginRateLimiter.recordSuccessfulLogin(this.email, () => {
this.RateLimiter.clearRateLimit.callCount.should.equal(1)
this.RateLimiter.clearRateLimit
@@ -73,14 +73,14 @@ describe('OneTimeTokenHandler', function() {
.should.equal(true)
})
return it('should call the callback with the token', function() {
it('should call the callback with the token', function() {
return this.callback
.calledWith(null, this.stubbedToken)
.should.equal(true)
})
})
return describe('with an optional expiresIn parameter', function() {
describe('with an optional expiresIn parameter', function() {
beforeEach(function() {
return this.OneTimeTokenHandler.getNewToken(
'password',
@@ -102,7 +102,7 @@ describe('OneTimeTokenHandler', function() {
.should.equal(true)
})
return it('should call the callback with the token', function() {
it('should call the callback with the token', function() {
return this.callback
.calledWith(null, this.stubbedToken)
.should.equal(true)
@@ -110,7 +110,7 @@ describe('OneTimeTokenHandler', function() {
})
})
return describe('getValueFromTokenAndExpire', function() {
describe('getValueFromTokenAndExpire', function() {
describe('successfully', function() {
beforeEach(function() {
this.db.tokens.findAndModify = sinon
@@ -139,12 +139,12 @@ describe('OneTimeTokenHandler', function() {
.should.equal(true)
})
return it('should return the data', function() {
it('should return the data', function() {
return this.callback.calledWith(null, 'mock-data').should.equal(true)
})
})
return describe('when a valid token is not found', function() {
describe('when a valid token is not found', function() {
beforeEach(function() {
this.db.tokens.findAndModify = sinon.stub().yields(null, null)
return this.OneTimeTokenHandler.getValueFromTokenAndExpire(
@@ -154,7 +154,7 @@ describe('OneTimeTokenHandler', function() {
)
})
return it('should return a NotFoundError', function() {
it('should return a NotFoundError', function() {
return this.callback
.calledWith(sinon.match.instanceOf(Errors.NotFoundError))
.should.equal(true)
@@ -49,7 +49,7 @@ describe('RateLimiterMiddleware', function() {
return (this.next = sinon.stub())
})
return describe('rateLimit', function() {
describe('rateLimit', function() {
beforeEach(function() {
this.rateLimiter = this.RateLimiterMiddleware.rateLimit({
endpointName: 'test-endpoint',
@@ -81,7 +81,7 @@ describe('RateLimiterMiddleware', function() {
.should.equal(true)
})
return it('should pass on to next()', function() {})
it('should pass on to next()', function() {})
})
describe('when under the rate limit with logged in user', function() {
@@ -106,7 +106,7 @@ describe('RateLimiterMiddleware', function() {
.should.equal(true)
})
return it('should pass on to next()', function() {
it('should pass on to next()', function() {
return this.next.called.should.equal(true)
})
})
@@ -129,12 +129,12 @@ describe('RateLimiterMiddleware', function() {
.should.equal(true)
})
return it('should pass on to next()', function() {
it('should pass on to next()', function() {
return this.next.called.should.equal(true)
})
})
return describe('when over the rate limit', function() {
describe('when over the rate limit', function() {
beforeEach(function() {
this.req.session = {
user: {
@@ -154,7 +154,7 @@ describe('RateLimiterMiddleware', function() {
return this.next.called.should.equal(false)
})
return it('should log a warning', function() {
it('should log a warning', function() {
return this.logger.warn
.calledWith(
{
@@ -144,7 +144,7 @@ describe('FeaturesUpdater', function() {
})
})
return describe('_mergeFeatures', function() {
describe('_mergeFeatures', function() {
it('should prefer priority over standard for compileGroup', function() {
expect(
this.FeaturesUpdater._mergeFeatures(
@@ -262,7 +262,7 @@ describe('FeaturesUpdater', function() {
})
})
return it('should prefer the true over false for other keys', function() {
it('should prefer the true over false for other keys', function() {
expect(
this.FeaturesUpdater._mergeFeatures(
{
@@ -78,14 +78,14 @@ describe('LimitationsManager', function() {
)
})
return it('should return the default number', function() {
it('should return the default number', function() {
return this.callback
.calledWith(null, this.Settings.defaultFeatures.collaborators)
.should.equal(true)
})
})
return describe('when the project is owned by a user with a subscription', function() {
describe('when the project is owned by a user with a subscription', function() {
beforeEach(function() {
this.project.owner_ref = this.user_id
this.user.features = { collaborators: 21 }
@@ -96,7 +96,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return the number of collaborators the user is allowed', function() {
it('should return the number of collaborators the user is allowed', function() {
return this.callback
.calledWith(null, this.user.features.collaborators)
.should.equal(true)
@@ -116,14 +116,14 @@ describe('LimitationsManager', function() {
)
})
return it('should return the default number', function() {
it('should return the default number', function() {
return this.callback
.calledWith(null, this.Settings.defaultFeatures.collaborators)
.should.equal(true)
})
})
return describe('when the user has features', function() {
describe('when the user has features', function() {
beforeEach(function() {
this.user.features = { collaborators: 21 }
this.callback = sinon.stub()
@@ -133,7 +133,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return the number of collaborators the user is allowed', function() {
it('should return the number of collaborators the user is allowed', function() {
return this.callback
.calledWith(null, this.user.features.collaborators)
.should.equal(true)
@@ -170,7 +170,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return true', function() {
it('should return true', function() {
return this.callback.calledWith(null, true).should.equal(true)
})
})
@@ -203,7 +203,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return true', function() {
it('should return true', function() {
return this.callback.calledWith(null, true).should.equal(true)
})
})
@@ -236,7 +236,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
@@ -269,7 +269,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
@@ -302,7 +302,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return true', function() {
it('should return true', function() {
return this.callback.calledWith(null, true).should.equal(true)
})
})
@@ -335,12 +335,12 @@ describe('LimitationsManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
return describe('when the project has more invites and collaborators than allowed', function() {
describe('when the project has more invites and collaborators than allowed', function() {
beforeEach(function() {
this.current_number = 1
this.allowed_number = 2
@@ -368,7 +368,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
@@ -432,7 +432,7 @@ describe('LimitationsManager', function() {
})
})
return describe('when user has a custom account', function() {
describe('when user has a custom account', function() {
beforeEach(function() {
this.fakeSubscription = { customAccount: true }
return this.SubscriptionLocator.getUsersSubscription.callsArgWith(
@@ -452,7 +452,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return the subscription', function(done) {
it('should return the subscription', function(done) {
return this.LimitationsManager.userHasV2Subscription(
this.user,
(err, hasSubscription, subscription) => {
@@ -480,7 +480,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return true if there are no groups subcriptions', function(done) {
it('should return true if there are no groups subcriptions', function(done) {
let subscriptions
this.SubscriptionLocator.getMemberSubscriptions.callsArgWith(
1,
@@ -560,7 +560,7 @@ describe('LimitationsManager', function() {
})
})
return it('should have userHasSubscriptionOrIsGroupMember alias', function(done) {
it('should have userHasSubscriptionOrIsGroupMember alias', function(done) {
return this.LimitationsManager.userHasSubscriptionOrIsGroupMember(
this.user,
function(err, hasSubOrIsGroupMember) {
@@ -607,7 +607,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return false if none are true', function(done) {
it('should return false if none are true', function(done) {
return this.LimitationsManager.userHasV1OrV2Subscription(
this.user,
function(err, hasSub) {
@@ -661,7 +661,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return true if the limit has been exceded (including members and invites)', function(done) {
it('should return true if the limit has been exceded (including members and invites)', function(done) {
this.subscription.membersLimit = 2
this.SubscriptionLocator.getSubscription.callsArgWith(
1,
@@ -678,7 +678,7 @@ describe('LimitationsManager', function() {
})
})
return describe('userHasV1Subscription', function() {
describe('userHasV1Subscription', function() {
it('should return true if v1 returns has_subscription = true', function(done) {
this.V1SubscriptionManager.getSubscriptionsFromV1 = sinon
.stub()
@@ -711,7 +711,7 @@ describe('LimitationsManager', function() {
)
})
return it('should return false if v1 returns nothing', function(done) {
it('should return false if v1 returns nothing', function(done) {
this.V1SubscriptionManager.getSubscriptionsFromV1 = sinon
.stub()
.yields(null, null)
@@ -185,7 +185,7 @@ describe('RecurlyWrapper', function() {
)
})
return it('should return the subscription', function() {
it('should return the subscription', function() {
return this.recurlySubscription.uuid.should.equal(
'44f83d7cba354d5b84812419f923ea96'
)
@@ -217,14 +217,14 @@ describe('RecurlyWrapper', function() {
)
})
return it('should look up the subscription at the RecurlyJS API end point', function() {
it('should look up the subscription at the RecurlyJS API end point', function() {
return this.apiRequest.args[0][0].url.should.equal(
'recurly_js/result/70db44b10f5f4b238669480c9903f6f5'
)
})
})
return describe('with includeAccount', function() {
describe('with includeAccount', function() {
beforeEach(function() {
this.apiRequest = sinon.stub(
this.RecurlyWrapper,
@@ -247,7 +247,7 @@ describe('RecurlyWrapper', function() {
return this.apiRequest.args[1][0].url.should.equal('accounts/104')
})
return it('should populate the account attribute', function() {
it('should populate the account attribute', function() {
return this.recurlySubscription.account.account_code.should.equal('104')
})
})
@@ -296,7 +296,7 @@ describe('RecurlyWrapper', function() {
return this.requestOptions.method.should.equal('put')
})
return it('should return the updated subscription', function() {
it('should return the updated subscription', function() {
should.exist(this.recurlySubscription)
return this.recurlySubscription.plan.plan_code.should.equal('gold')
})
@@ -330,7 +330,7 @@ describe('RecurlyWrapper', function() {
return this.apiRequest.called.should.equal(true)
})
return describe('when the subscription is already cancelled', function() {
describe('when the subscription is already cancelled', function() {
beforeEach(function() {
this.RecurlyWrapper.apiRequest.restore()
this.recurlySubscriptionId = 'subscription-id-123'
@@ -347,7 +347,7 @@ describe('RecurlyWrapper', function() {
))
})
return it('should not produce an error', function(done) {
it('should not produce an error', function(done) {
return this.RecurlyWrapper.cancelSubscription(
this.recurlySubscriptionId,
err => {
@@ -383,7 +383,7 @@ describe('RecurlyWrapper', function() {
return this.RecurlyWrapper.apiRequest.restore()
})
return it('should send a cancel request to the API', function() {
it('should send a cancel request to the API', function() {
return this.apiRequest.called.should.equal(true)
})
})
@@ -412,7 +412,7 @@ describe('RecurlyWrapper', function() {
return this.RecurlyWrapper.apiRequest.restore()
})
return it('sends correct XML', function() {
it('sends correct XML', function() {
this.apiRequest.called.should.equal(true)
const { body } = this.apiRequest.lastCall.args[0]
return expect(body).to.equal(`\
@@ -452,7 +452,7 @@ describe('RecurlyWrapper', function() {
return this.RecurlyWrapper.apiRequest.restore()
})
return it('sends correct XML', function() {
it('sends correct XML', function() {
this.apiRequest.called.should.equal(true)
const { body } = this.apiRequest.lastCall.args[0]
return expect(body).to.equal(`\
@@ -543,7 +543,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when _createPaypalSubscription produces an error', function() {
describe('when _createPaypalSubscription produces an error', function() {
beforeEach(function() {
return this._createPaypalSubscription.callsArgWith(
3,
@@ -551,7 +551,7 @@ describe('RecurlyWrapper', function() {
)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, sub) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -560,7 +560,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when not paypal', function() {
describe('when not paypal', function() {
beforeEach(function() {
this.subscriptionDetails.isPaypal = false
this._createCreditCardSubscription = sinon.stub(
@@ -600,7 +600,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when _createCreditCardSubscription produces an error', function() {
describe('when _createCreditCardSubscription produces an error', function() {
beforeEach(function() {
return this._createCreditCardSubscription.callsArgWith(
3,
@@ -608,7 +608,7 @@ describe('RecurlyWrapper', function() {
)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, sub) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -737,7 +737,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should not _parseSubscriptionXml', function(done) {
it('should not _parseSubscriptionXml', function(done) {
return this.call((err, sub) => {
this._parseSubscriptionXml.callCount.should.equal(0)
return done()
@@ -745,12 +745,12 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when parse xml produces an error', function() {
describe('when parse xml produces an error', function() {
beforeEach(function() {
return this._parseSubscriptionXml.callsArgWith(1, new Error('woops'))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, sub) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -887,7 +887,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when one of the paypal stages produces an error', function() {
describe('when one of the paypal stages produces an error', function() {
beforeEach(function() {
return this.createAccount.callsArgWith(1, new Error('woops'))
})
@@ -899,7 +899,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should stop calling the paypal stages after the error', function(done) {
it('should stop calling the paypal stages after the error', function(done) {
return this.call((err, sub) => {
this.checkAccountExists.callCount.should.equal(1)
this.createAccount.callCount.should.equal(1)
@@ -1010,7 +1010,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should set userExists to true', function(done) {
it('should set userExists to true', function(done) {
return this.call((err, result) => {
expect(result.userExists).to.equal(true)
return done()
@@ -1052,7 +1052,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should set userExists to false', function(done) {
it('should set userExists to false', function(done) {
return this.call((err, result) => {
expect(result.userExists).to.equal(false)
return done()
@@ -1060,14 +1060,14 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when apiRequest produces an error', function() {
describe('when apiRequest produces an error', function() {
beforeEach(function() {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
statusCode: 500
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1088,7 +1088,7 @@ describe('RecurlyWrapper', function() {
return (this.cache.subscriptionDetails.address = null)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1126,7 +1126,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should not call _parseAccountXml', function(done) {
it('should not call _parseAccountXml', function(done) {
return this.call((err, result) => {
this.RecurlyWrapper._parseAccountXml.callCount.should.equal(0)
return done()
@@ -1134,7 +1134,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when account does not exist', function() {
describe('when account does not exist', function() {
beforeEach(function() {
this.cache.userExists = false
const resultXml =
@@ -1192,14 +1192,14 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when apiRequest produces an error', function() {
describe('when apiRequest produces an error', function() {
beforeEach(function() {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
statusCode: 500
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1225,7 +1225,7 @@ describe('RecurlyWrapper', function() {
return (this.cache.account.account_code = null)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1278,7 +1278,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should set billingInfo on cache', function(done) {
it('should set billingInfo on cache', function(done) {
return this.call((err, result) => {
expect(result.billingInfo).to.deep.equal({
a: '1'
@@ -1288,14 +1288,14 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when apiRequest produces an error', function() {
describe('when apiRequest produces an error', function() {
beforeEach(function() {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
statusCode: 500
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1318,7 +1318,7 @@ describe('RecurlyWrapper', function() {
return (this.cache.account.account_code = null)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1331,7 +1331,7 @@ describe('RecurlyWrapper', function() {
return (this.cache.subscriptionDetails.address = null)
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1389,7 +1389,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should set billingInfo on cache', function(done) {
it('should set billingInfo on cache', function(done) {
return this.call((err, result) => {
expect(result.billingInfo).to.deep.equal({
city: 'London'
@@ -1399,14 +1399,14 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when apiRequest produces an error', function() {
describe('when apiRequest produces an error', function() {
beforeEach(function() {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
statusCode: 500
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1415,7 +1415,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('_paypal.createSubscription', function() {
describe('_paypal.createSubscription', function() {
beforeEach(function() {
this.cache.account = { account_code: 'abc' }
this.cache.billingInfo = {}
@@ -1477,7 +1477,7 @@ describe('RecurlyWrapper', function() {
})
})
return it('should set subscription on cache', function(done) {
it('should set subscription on cache', function(done) {
return this.call((err, result) => {
expect(result.subscription).to.deep.equal({
a: '1'
@@ -1487,14 +1487,14 @@ describe('RecurlyWrapper', function() {
})
})
return describe('when apiRequest produces an error', function() {
describe('when apiRequest produces an error', function() {
beforeEach(function() {
return this.apiRequest.callsArgWith(1, new Error('woops'), {
statusCode: 500
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, result) => {
expect(err).to.be.instanceof(Error)
return done()
@@ -1504,7 +1504,7 @@ describe('RecurlyWrapper', function() {
})
})
return describe('listAccountActiveSubscriptions', function() {
describe('listAccountActiveSubscriptions', function() {
beforeEach(function() {
this.user_id = 'mock-user-id'
this.callback = sinon.stub()
@@ -1540,14 +1540,14 @@ describe('RecurlyWrapper', function() {
.should.equal(true)
})
return it('should return the subscriptions', function() {
it('should return the subscriptions', function() {
return this.callback
.calledWith(null, this.subscriptions)
.should.equal(true)
})
})
return describe('without an account', function() {
describe('without an account', function() {
beforeEach(function() {
this.response.statusCode = 404
return this.RecurlyWrapper.listAccountActiveSubscriptions(
@@ -1556,7 +1556,7 @@ describe('RecurlyWrapper', function() {
)
})
return it('should return an empty array of subscriptions', function() {
it('should return an empty array of subscriptions', function() {
return this.callback.calledWith(null, []).should.equal(true)
})
})
@@ -140,7 +140,7 @@ describe('SubscriptionController', function() {
return done()
})
return describe('not dependant on logged in state', function(done) {
describe('not dependant on logged in state', function(done) {
// these could have been put in 'when user is not logged in' too
it('should set the recommended currency from the geoiplookup', function(done) {
this.res.renderedVariables.recomendedCurrency.should.equal(
@@ -151,14 +151,14 @@ describe('SubscriptionController', function() {
.should.equal(true)
return done()
})
return it('should include data for features table', function(done) {
it('should include data for features table', function(done) {
this.res.renderedVariables.planFeatures.length.should.not.equal(0)
return done()
})
})
})
return describe('when user is not logged in', function(done) {
describe('when user is not logged in', function(done) {
beforeEach(function(done) {
this.res.callback = done
this.AuthenticationController.getLoggedInUserId = sinon
@@ -167,7 +167,7 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.plansPage(this.req, this.res)
})
return it('should not fetch the current user', function(done) {
it('should not fetch the current user', function(done) {
this.UserGetter.getUser.callCount.should.equal(0)
return done()
})
@@ -197,7 +197,7 @@ describe('SubscriptionController', function() {
return this.PlansLocator.findLocalPlanInSettings.returns({})
})
return describe('with a valid plan code', () =>
describe('with a valid plan code', () =>
it('should render the new subscription page', function(done) {
this.res.render = (page, opts) => {
page.should.equal('subscriptions/new')
@@ -265,7 +265,7 @@ describe('SubscriptionController', function() {
return this.SubscriptionController.paymentPage(this.req, this.res)
})
return it('should use the geo ip currency if non is provided', function(done) {
it('should use the geo ip currency if non is provided', function(done) {
this.req.query.currency = null
this.res.render = (page, opts) => {
opts.currency.should.equal(this.stubbedCurrencyCode)
@@ -275,7 +275,7 @@ describe('SubscriptionController', function() {
})
})
return describe('with a recurly subscription already', () =>
describe('with a recurly subscription already', () =>
it('should redirect to the subscription dashboard', function(done) {
this.LimitationsManager.userHasV1OrV2Subscription.callsArgWith(
1,
@@ -353,7 +353,7 @@ describe('SubscriptionController', function() {
return expect(this.data.user).to.deep.equal(this.user)
})
return it('should load the plans', function() {
it('should load the plans', function() {
return expect(this.data.plans).to.deep.equal(this.plans)
})
})
@@ -387,7 +387,7 @@ describe('SubscriptionController', function() {
return done()
})
return it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function(done) {
this.res.sendStatus.calledWith(201).should.equal(true)
return done()
})
@@ -413,7 +413,7 @@ describe('SubscriptionController', function() {
return done()
})
return it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function(done) {
this.res.redirect.calledWith('/user/subscription').should.equal(true)
return done()
})
@@ -440,7 +440,7 @@ describe('SubscriptionController', function() {
return done()
})
return it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function(done) {
this.res.redirect.calledWith('/user/subscription').should.equal(true)
return done()
})
@@ -464,7 +464,7 @@ describe('SubscriptionController', function() {
return done()
})
return it('should redurect to the subscription page', function(done) {
it('should redurect to the subscription page', function(done) {
this.res.redirect
.calledWith('/user/subscription/canceled')
.should.equal(true)
@@ -498,13 +498,13 @@ describe('SubscriptionController', function() {
return done()
})
return it('should send a 200', function(done) {
it('should send a 200', function(done) {
this.res.sendStatus.calledWith(200)
return done()
})
})
return describe('with a non-actionable request', function() {
describe('with a non-actionable request', function() {
beforeEach(function(done) {
this.user.id = this.activeRecurlySubscription.account.account_code
this.req = {
@@ -531,7 +531,7 @@ describe('SubscriptionController', function() {
)
})
return it('should respond with a 200 status', function() {
it('should respond with a 200 status', function() {
return this.res.sendStatus.calledWith(200)
})
})
@@ -585,7 +585,7 @@ describe('SubscriptionController', function() {
)
})
return it('should pass annual as the plan name if the user is already on an annual plan', function(done) {
it('should pass annual as the plan name if the user is already on an annual plan', function(done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(
1,
null,
@@ -603,7 +603,7 @@ describe('SubscriptionController', function() {
})
})
return describe('processUpgradeToAnnualPlan', function() {
describe('processUpgradeToAnnualPlan', function() {
beforeEach(function() {})
it('should tell the subscription handler to update the subscription with the annual plan and apply a coupon code', function(done) {
@@ -622,7 +622,7 @@ describe('SubscriptionController', function() {
)
})
return it('should get the collaborator coupon code', function(done) {
it('should get the collaborator coupon code', function(done) {
this.req.body = { planName: 'collaborator' }
this.res.sendStatus = url => {
@@ -71,7 +71,7 @@ describe('SubscriptionGroupController', function() {
}))
})
return describe('removeUserFromGroup', () =>
describe('removeUserFromGroup', () =>
it('should use the subscription id for the logged in user and take the user id from the params', function(done) {
const userIdToRemove = '31231'
this.req.params = { user_id: userIdToRemove }
@@ -162,7 +162,7 @@ describe('SubscriptionGroupHandler', function() {
.should.equal(true)
})
return it('replaces the member ids', function() {
it('replaces the member ids', function() {
this.Subscription.update
.calledWith(
{ member_ids: this.oldId },
@@ -200,7 +200,7 @@ describe('SubscriptionGroupHandler', function() {
)
})
return it('should return false when no subscription is found', function(done) {
it('should return false when no subscription is found', function(done) {
this.SubscriptionLocator.getSubscriptionByMemberIdAndId.callsArgWith(
2,
null
@@ -216,12 +216,12 @@ describe('SubscriptionGroupHandler', function() {
})
})
return describe('getTotalConfirmedUsersInGroup', function() {
describe('getTotalConfirmedUsersInGroup', function() {
describe('for existing subscriptions', function() {
beforeEach(function() {
return (this.subscription.member_ids = ['12321', '3121321'])
})
return it('should call the subscription locator and return 2 users', function(done) {
it('should call the subscription locator and return 2 users', function(done) {
return this.Handler.getTotalConfirmedUsersInGroup(
this.subscription_id,
(err, count) => {
@@ -234,7 +234,7 @@ describe('SubscriptionGroupHandler', function() {
)
})
})
return describe('for nonexistent subscriptions', () =>
describe('for nonexistent subscriptions', () =>
it('should return undefined', function(done) {
return this.Handler.getTotalConfirmedUsersInGroup(
'fake-id',
@@ -141,7 +141,7 @@ describe('SubscriptionHandler', function() {
.should.equal(true)
})
return it('should sync the subscription to the user', function() {
it('should sync the subscription to the user', function() {
this.SubscriptionUpdater.syncSubscription.calledOnce.should.equal(true)
this.SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal(
this.activeRecurlySubscription
@@ -152,7 +152,7 @@ describe('SubscriptionHandler', function() {
})
})
return describe('when there is already a subscription in Recurly', function() {
describe('when there is already a subscription in Recurly', function() {
beforeEach(function() {
this.SubscriptionHandler.validateNoSubscriptionInRecurly = sinon
.stub()
@@ -165,7 +165,7 @@ describe('SubscriptionHandler', function() {
)
})
return it('should return an error', function() {
it('should return an error', function() {
return this.callback.calledWith(
new Error('user already has subscription in recurly')
)
@@ -207,7 +207,7 @@ describe('SubscriptionHandler', function() {
return updateOptions.timeframe.should.equal('now')
})
return it('should sync the new subscription to the user', function() {
it('should sync the new subscription to the user', function() {
this.SubscriptionUpdater.syncSubscription.calledOnce.should.equal(
true
)
@@ -235,7 +235,7 @@ describe('SubscriptionHandler', function() {
)
})
return it('should redirect to the subscription dashboard', function() {
it('should redirect to the subscription dashboard', function() {
this.RecurlyWrapper.updateSubscription.called.should.equal(false)
return this.SubscriptionHandler.syncSubscriptionToUser.called.should.equal(
false
@@ -243,7 +243,7 @@ describe('SubscriptionHandler', function() {
})
})
return describe('with a coupon code', function() {
describe('with a coupon code', function() {
beforeEach(function(done) {
this.plan_code = 'collaborator'
this.coupon_code = '1231312'
@@ -277,7 +277,7 @@ describe('SubscriptionHandler', function() {
return done()
})
return it('should update the subscription', function() {
it('should update the subscription', function() {
this.RecurlyWrapper.updateSubscription
.calledWith(this.subscription.recurlySubscription_id)
.should.equal(true)
@@ -299,12 +299,12 @@ describe('SubscriptionHandler', function() {
return this.SubscriptionHandler.cancelSubscription(this.user, done)
})
return it('should redirect to the subscription dashboard', function() {
it('should redirect to the subscription dashboard', function() {
return this.RecurlyWrapper.cancelSubscription.called.should.equal(false)
})
})
return describe('with a user with a subscription', function() {
describe('with a user with a subscription', function() {
beforeEach(function(done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(
1,
@@ -322,7 +322,7 @@ describe('SubscriptionHandler', function() {
.should.equal(true)
})
return it('should trigger the cancel subscription event', function() {
it('should trigger the cancel subscription event', function() {
return this.Events.emit
.calledWith('cancelSubscription', this.user._id)
.should.equal(true)
@@ -348,12 +348,12 @@ describe('SubscriptionHandler', function() {
)
})
return it('should not send a notification email', function() {
it('should not send a notification email', function() {
return sinon.assert.notCalled(this.EmailHandler.sendEmail)
})
})
return describe('with a user with a subscription', function() {
describe('with a user with a subscription', function() {
beforeEach(function(done) {
this.LimitationsManager.userHasV2Subscription.callsArgWith(
1,
@@ -371,7 +371,7 @@ describe('SubscriptionHandler', function() {
.should.equal(true)
})
return it('should send a notification email', function() {
it('should send a notification email', function() {
return sinon.assert.calledWith(
this.EmailHandler.sendEmail,
'reactivatedSubscription'
@@ -406,7 +406,7 @@ describe('SubscriptionHandler', function() {
return options.includeAccount.should.equal(true)
})
return it('should sync the subscription to the user', function() {
it('should sync the subscription to the user', function() {
this.SubscriptionUpdater.syncSubscription.calledOnce.should.equal(true)
this.SubscriptionUpdater.syncSubscription.args[0][0].should.deep.equal(
this.activeRecurlySubscription
@@ -417,7 +417,7 @@ describe('SubscriptionHandler', function() {
})
}))
return describe('validateNoSubscriptionInRecurly', function() {
describe('validateNoSubscriptionInRecurly', function() {
beforeEach(function() {
this.subscriptions = []
this.RecurlyWrapper.listAccountActiveSubscriptions = sinon
@@ -448,12 +448,12 @@ describe('SubscriptionHandler', function() {
.should.equal(true)
})
return it('should call the callback with valid == false', function() {
it('should call the callback with valid == false', function() {
return this.callback.calledWith(null, false).should.equal(true)
})
})
return describe('with a subscription in recurly', function() {
describe('with a subscription in recurly', function() {
beforeEach(function() {
return this.SubscriptionHandler.validateNoSubscriptionInRecurly(
this.user_id,
@@ -467,7 +467,7 @@ describe('SubscriptionHandler', function() {
)
})
return it('should call the callback with valid == true', function() {
it('should call the callback with valid == true', function() {
return this.callback.calledWith(null, true).should.equal(true)
})
})
@@ -39,7 +39,7 @@ describe('Subscription Locator Tests', function() {
}))
})
return describe('finding users subscription', function() {
describe('finding users subscription', function() {
it('should send the users features', function(done) {
this.Subscription.findOne.callsArgWith(1, null, this.subscription)
return this.SubscriptionLocator.getUsersSubscription(
@@ -79,7 +79,7 @@ describe('Subscription Locator Tests', function() {
)
})
return describe('finding managed subscription', () =>
describe('finding managed subscription', () =>
it('should query the database', function(done) {
this.Subscription.findOne.callsArgWith(1, null, this.subscription)
return this.SubscriptionLocator.findManagedSubscription(
@@ -34,7 +34,7 @@ describe('UserFeaturesUpdater', function() {
}))
})
return describe('updateFeatures', () =>
describe('updateFeatures', () =>
it('should send the users features', function(done) {
const user_id = '5208dd34438842e2db000005'
this.features = { versioning: true, collaborators: 10 }
@@ -73,7 +73,7 @@ describe('V1SubscriptionManager', function() {
})
})
return describe('when all goes well', function() {
describe('when all goes well', function() {
it('should call _v1Request', function(done) {
return this.call((err, planCode) => {
expect(this.V1SubscriptionManager._v1Request.callCount).to.equal(1)
@@ -99,12 +99,12 @@ describe('V1SubscriptionManager', function() {
})
})
return describe('when the plan_name from v1 is null', function() {
describe('when the plan_name from v1 is null', function() {
beforeEach(function() {
return (this.responseBody.plan_name = null)
})
return it('should produce a null plan-code without error', function(done) {
it('should produce a null plan-code without error', function(done) {
return this.call((err, planCode) => {
expect(err).to.not.exist
expect(planCode).to.equal(null)
@@ -124,7 +124,7 @@ describe('V1SubscriptionManager', function() {
return done()
}))
return describe('when the user ID is less than the cutoff', () =>
describe('when the user ID is less than the cutoff', () =>
it('should return a feature set with grandfathered properties for github and mendeley', function(done) {
expect(
this.V1SubscriptionManager.getGrandfatheredFeaturesForV1User(1)
@@ -166,7 +166,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, planCode) => {
expect(err).to.exist
return done()
@@ -197,7 +197,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should not error', function(done) {
it('should not error', function(done) {
return this.call(err => {
expect(err).to.not.exist
return done()
@@ -221,7 +221,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.exist
return done()
@@ -262,7 +262,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should return the http response body', function(done) {
it('should return the http response body', function(done) {
return this.call((err, body, v1Id) => {
expect(body).to.equal('{}')
return done()
@@ -289,7 +289,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, body, v1Id) => {
expect(err).to.exist
return done()
@@ -297,7 +297,7 @@ describe('V1SubscriptionManager', function() {
})
})
return describe('when the call returns an http not-found status code', function() {
describe('when the call returns an http not-found status code', function() {
beforeEach(function() {
this.V1SubscriptionManager.v1IdForUser = sinon
.stub()
@@ -316,7 +316,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should produce an not-found error', function(done) {
it('should produce an not-found error', function(done) {
return this.call((err, body, v1Id) => {
expect(err).to.exist
expect(err.name).to.equal('NotFoundError')
@@ -326,7 +326,7 @@ describe('V1SubscriptionManager', function() {
})
})
return describe('v1IdForUser', function() {
describe('v1IdForUser', function() {
beforeEach(function() {
return (this.UserGetter.getUser = sinon.stub().yields(null, this.user))
})
@@ -339,7 +339,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.exist
return done()
@@ -355,7 +355,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should not error', function(done) {
it('should not error', function(done) {
return this.call((err, user_id) => {
expect(err).to.not.exist
return done()
@@ -363,7 +363,7 @@ describe('V1SubscriptionManager', function() {
})
})
return describe('when it works', function() {
describe('when it works', function() {
beforeEach(function() {
return (this.call = cb => {
return this.V1SubscriptionManager.v1IdForUser(this.user_id, cb)
@@ -377,7 +377,7 @@ describe('V1SubscriptionManager', function() {
})
})
return it('should return the v1 user id', function(done) {
it('should return the v1 user id', function(done) {
return this.call((err, user_id) => {
expect(user_id).to.eql(42)
return done()
@@ -116,13 +116,13 @@ describe('SudoModeController', function() {
return expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
})
return it('should not render page', function() {
it('should not render page', function() {
this.SudoModeController.sudoModePrompt(this.req, this.res, this.next)
return this.res.render.callCount.should.equal(0)
})
})
return describe('when external auth system is used', function() {
describe('when external auth system is used', function() {
beforeEach(function() {
return (this.req.externalAuthenticationSystemUsed = sinon
.stub()
@@ -140,14 +140,14 @@ describe('SudoModeController', function() {
return this.SudoModeHandler.isSudoModeActive.callCount.should.equal(0)
})
return it('should not render page', function() {
it('should not render page', function() {
this.SudoModeController.sudoModePrompt(this.req, this.res, this.next)
return this.res.render.callCount.should.equal(0)
})
})
})
return describe('submitPassword', function() {
describe('submitPassword', function() {
beforeEach(function() {
this.AuthenticationController._getRedirectFromSession = sinon
.stub()
@@ -163,7 +163,7 @@ describe('SudoModeController', function() {
return (this.next = sinon.stub())
})
return describe('when all goes well', function() {
describe('when all goes well', function() {
beforeEach(function() {})
it('should get the logged in user id', function() {
@@ -250,7 +250,7 @@ describe('SudoModeController', function() {
return this.SudoModeHandler.activateSudoMode.callCount.should.equal(0)
})
return it('should not send back a json response', function() {
it('should not send back a json response', function() {
this.SudoModeController.submitPassword(this.req, this.res, this.next)
return this.res.json.callCount.should.equal(0)
})
@@ -288,7 +288,7 @@ describe('SudoModeController', function() {
return this.SudoModeHandler.activateSudoMode.callCount.should.equal(0)
})
return it('should not send back a json response', function() {
it('should not send back a json response', function() {
this.SudoModeController.submitPassword(this.req, this.res, this.next)
return this.res.json.callCount.should.equal(0)
})
@@ -324,7 +324,7 @@ describe('SudoModeController', function() {
return this.SudoModeHandler.activateSudoMode.callCount.should.equal(0)
})
return it('should not send back a json response', function() {
it('should not send back a json response', function() {
this.SudoModeController.submitPassword(this.req, this.res, this.next)
return this.res.json.callCount.should.equal(0)
})
@@ -367,7 +367,7 @@ describe('SudoModeController', function() {
.should.equal(true)
})
return it('should not activate sudo mode', function() {
it('should not activate sudo mode', function() {
this.SudoModeController.submitPassword(this.req, this.res, this.next)
return this.SudoModeHandler.activateSudoMode.callCount.should.equal(0)
})
@@ -403,13 +403,13 @@ describe('SudoModeController', function() {
.should.equal(true)
})
return it('should not activate sudo mode', function() {
it('should not activate sudo mode', function() {
this.SudoModeController.submitPassword(this.req, this.res, this.next)
return this.SudoModeHandler.activateSudoMode.callCount.should.equal(0)
})
})
return describe('when sudo mode activation produces an error', function() {
describe('when sudo mode activation produces an error', function() {
beforeEach(function() {
this.SudoModeHandler.activateSudoMode = sinon
.stub()
@@ -439,7 +439,7 @@ describe('SudoModeController', function() {
.should.equal(true)
})
return it('should have tried to activate sudo mode', function() {
it('should have tried to activate sudo mode', function() {
this.SudoModeController.submitPassword(this.req, this.res, this.next)
this.SudoModeHandler.activateSudoMode.callCount.should.equal(1)
return this.SudoModeHandler.activateSudoMode
@@ -72,7 +72,7 @@ describe('SudoModeHandler', function() {
})
})
return it('should set a value in redis', function(done) {
it('should set a value in redis', function(done) {
return this.call(err => {
expect(this.rclient.set.callCount).to.equal(1)
expect(
@@ -103,7 +103,7 @@ describe('SudoModeHandler', function() {
})
})
return it('should not set value in redis', function(done) {
it('should not set value in redis', function(done) {
return this.call(err => {
expect(this.rclient.set.callCount).to.equal(0)
return done()
@@ -111,14 +111,14 @@ describe('SudoModeHandler', function() {
})
})
return describe('when rclient.set produces an error', function() {
describe('when rclient.set produces an error', function() {
beforeEach(function() {
return (this.rclient.set = sinon
.stub()
.callsArgWith(4, new Error('woops')))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -160,7 +160,7 @@ describe('SudoModeHandler', function() {
.callsArgWith(1, new Error('woops')))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call(err => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -169,7 +169,7 @@ describe('SudoModeHandler', function() {
})
})
return describe('when user id is not supplied', function() {
describe('when user id is not supplied', function() {
beforeEach(function() {
return (this.call = cb => {
return this.SudoModeHandler.clearSudoMode(null, cb)
@@ -184,7 +184,7 @@ describe('SudoModeHandler', function() {
})
})
return it('should not delete value in redis', function(done) {
it('should not delete value in redis', function(done) {
return this.call(err => {
expect(this.rclient.del.callCount).to.equal(0)
return done()
@@ -200,7 +200,7 @@ describe('SudoModeHandler', function() {
.callsArgWith(2, null, this.user))
})
return it('should call AuthenticationManager.authenticate', function(done) {
it('should call AuthenticationManager.authenticate', function(done) {
return this.SudoModeHandler.authenticate(
this.email,
'password',
@@ -215,7 +215,7 @@ describe('SudoModeHandler', function() {
})
})
return describe('isSudoModeActive', function() {
describe('isSudoModeActive', function() {
beforeEach(function() {
return (this.call = cb => {
return this.SudoModeHandler.isSudoModeActive(this.userId, cb)
@@ -244,7 +244,7 @@ describe('SudoModeHandler', function() {
})
})
return it('should produce a true result', function(done) {
it('should produce a true result', function(done) {
return this.call((err, isActive) => {
expect(isActive).to.equal(true)
return done()
@@ -274,7 +274,7 @@ describe('SudoModeHandler', function() {
})
})
return it('should produce a false result', function(done) {
it('should produce a false result', function(done) {
return this.call((err, isActive) => {
expect(isActive).to.equal(false)
return done()
@@ -289,7 +289,7 @@ describe('SudoModeHandler', function() {
.callsArgWith(1, new Error('woops')))
})
return it('should produce an error', function(done) {
it('should produce an error', function(done) {
return this.call((err, isActive) => {
expect(err).to.not.equal(null)
expect(err).to.be.instanceof(Error)
@@ -299,7 +299,7 @@ describe('SudoModeHandler', function() {
})
})
return describe('when user id is not supplied', function() {
describe('when user id is not supplied', function() {
beforeEach(function() {
return (this.call = cb => {
return this.SudoModeHandler.isSudoModeActive(null, cb)
@@ -314,7 +314,7 @@ describe('SudoModeHandler', function() {
})
})
return it('should not get value in redis', function(done) {
it('should not get value in redis', function(done) {
return this.call(err => {
expect(this.rclient.get.callCount).to.equal(0)
return done()
@@ -39,7 +39,7 @@ describe('SudoModeMiddleware', function() {
}))
})
return describe('protectPage', function() {
describe('protectPage', function() {
beforeEach(function() {
this.externalAuth = false
return (this.call = cb => {
@@ -84,7 +84,7 @@ describe('SudoModeMiddleware', function() {
})
})
return it('should call next', function(done) {
it('should call next', function(done) {
return this.call(() => {
this.next.callCount.should.equal(1)
expect(this.next.lastCall.args[0]).to.equal(undefined)
@@ -135,7 +135,7 @@ describe('SudoModeMiddleware', function() {
})
})
return it('should redirect to the password-prompt page', function(done) {
it('should redirect to the password-prompt page', function(done) {
return this.call(() => {
this.res.redirect.callCount.should.equal(1)
this.res.redirect.calledWith('/confirm-password').should.equal(true)
@@ -173,7 +173,7 @@ describe('SudoModeMiddleware', function() {
})
})
return it('should call next with an error', function(done) {
it('should call next with an error', function(done) {
return this.call(() => {
this.next.callCount.should.equal(1)
expect(this.next.lastCall.args[0]).to.be.instanceof(Error)
@@ -182,7 +182,7 @@ describe('SudoModeMiddleware', function() {
})
})
return describe('when external auth is being used', function() {
describe('when external auth is being used', function() {
beforeEach(function() {
this.externalAuth = true
return (this.call = cb => {
@@ -215,7 +215,7 @@ describe('SudoModeMiddleware', function() {
})
})
return it('should not check if sudo-mode is active', function(done) {
it('should not check if sudo-mode is active', function(done) {
return this.call(() => {
this.SudoModeHandler.isSudoModeActive.callCount.should.equal(0)
return done()
@@ -51,14 +51,14 @@ describe('SystemMessageManager', function() {
return this.callback.calledWith(null, this.messages).should.equal(true)
})
return it('should cache the messages', function() {
it('should cache the messages', function() {
return this.SystemMessageManager._cachedMessages.should.equal(
this.messages
)
})
})
return describe('when the messages are cached', function() {
describe('when the messages are cached', function() {
beforeEach(function() {
this.SystemMessageManager._cachedMessages = this.messages
return this.SystemMessageManager.getMessages(this.callback)
@@ -68,13 +68,13 @@ describe('SystemMessageManager', function() {
return this.SystemMessage.find.called.should.equal(false)
})
return it('should return the messages', function() {
it('should return the messages', function() {
return this.callback.calledWith(null, this.messages).should.equal(true)
})
})
})
return describe('clearMessages', function() {
describe('clearMessages', function() {
beforeEach(function() {
this.SystemMessage.remove = sinon.stub().callsArg(1)
return this.SystemMessageManager.clearMessages(this.callback)
@@ -84,7 +84,7 @@ describe('SystemMessageManager', function() {
return this.SystemMessage.remove.calledWith({}).should.equal(true)
})
return it('should return the callback', function() {
it('should return the callback', function() {
return this.callback.called.should.equal(true)
})
})
@@ -93,7 +93,7 @@ describe('TagsController', function() {
.should.equal(true)
})
return it('should return the tag', function() {
it('should return the tag', function() {
return this.res.json.calledWith(this.tag).should.equal(true)
})
})
@@ -111,7 +111,7 @@ describe('TagsController', function() {
.should.equal(true)
})
return it('should return 204 status code', function() {
it('should return 204 status code', function() {
this.res.status.calledWith(204).should.equal(true)
return this.res.end.called.should.equal(true)
})
@@ -135,13 +135,13 @@ describe('TagsController', function() {
.should.equal(true)
})
return it('should return 204 status code', function() {
it('should return 204 status code', function() {
this.res.status.calledWith(204).should.equal(true)
return this.res.end.called.should.equal(true)
})
})
return describe('without a name', function() {
describe('without a name', function() {
beforeEach(function() {
return this.controller.renameTag(this.req, this.res)
})
@@ -150,7 +150,7 @@ describe('TagsController', function() {
return this.handler.renameTag.called.should.equal(false)
})
return it('should return 400 (bad request) status code', function() {
it('should return 400 (bad request) status code', function() {
this.res.status.calledWith(400).should.equal(true)
return this.res.end.called.should.equal(true)
})
@@ -171,13 +171,13 @@ describe('TagsController', function() {
.should.equal(true)
})
return it('should return 204 status code', function() {
it('should return 204 status code', function() {
this.res.status.calledWith(204).should.equal(true)
return this.res.end.called.should.equal(true)
})
})
return describe('removeProjectFromTag', function() {
describe('removeProjectFromTag', function() {
beforeEach(function() {
this.req.params.tag_id = this.tag_id = 'tag-id-123'
this.req.params.project_id = this.project_id = 'project-id-123'
@@ -191,7 +191,7 @@ describe('TagsController', function() {
.should.equal(true)
})
return it('should return 204 status code', function() {
it('should return 204 status code', function() {
this.res.status.calledWith(204).should.equal(true)
return this.res.end.called.should.equal(true)
})

Some files were not shown because too many files have changed in this diff Show More