mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
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:
parent
6fc507aea3
commit
757ae39487
170 changed files with 1691 additions and 1691 deletions
|
@ -84,7 +84,7 @@ describe('ApiClsiTests', function() {
|
|||
)
|
||||
}))
|
||||
|
||||
return describe('unauthorized', () =>
|
||||
describe('unauthorized', () =>
|
||||
it('returns 401', function(done) {
|
||||
return request.post(
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ describe('ApiClsiTests', function() {
|
|||
}))
|
||||
})
|
||||
|
||||
return describe('get output', function() {
|
||||
describe('get output', function() {
|
||||
describe('valid file', () =>
|
||||
it('returns the file', done =>
|
||||
authed_request.get(
|
||||
|
@ -132,7 +132,7 @@ describe('ApiClsiTests', function() {
|
|||
}
|
||||
)))
|
||||
|
||||
return describe('unauthorized', () =>
|
||||
describe('unauthorized', () =>
|
||||
it('returns 401', done =>
|
||||
request.get(
|
||||
'/api/clsi/compile/abcd/build/1234/output/project.pdf',
|
||||
|
|
|
@ -393,7 +393,7 @@ describe('Authorization', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should allow site admin users admin access to it', function(done) {
|
||||
it('should allow site admin users admin access to it', function(done) {
|
||||
return expect_admin_access(this.site_admin, this.project_id, done)
|
||||
})
|
||||
})
|
||||
|
@ -472,7 +472,7 @@ describe('Authorization', function() {
|
|||
return expect_settings_write_access(this.rw_user, this.project_id, done)
|
||||
})
|
||||
|
||||
return it('should not allow the read-write user admin access to it', function(done) {
|
||||
it('should not allow the read-write user admin access to it', function(done) {
|
||||
return expect_no_admin_access(
|
||||
this.rw_user,
|
||||
this.project_id,
|
||||
|
@ -539,7 +539,7 @@ describe('Authorization', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow an anonymous user admin access to it', function(done) {
|
||||
it('should not allow an anonymous user admin access to it', function(done) {
|
||||
return expect_no_admin_access(
|
||||
this.anon,
|
||||
this.project_id,
|
||||
|
@ -549,7 +549,7 @@ describe('Authorization', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('public read-only project', function() {
|
||||
describe('public read-only project', function() {
|
||||
before(function(done) {
|
||||
return this.owner.createProject(
|
||||
'public-ro-project',
|
||||
|
@ -606,7 +606,7 @@ describe('Authorization', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow an anonymous user admin access to it', function(done) {
|
||||
it('should not allow an anonymous user admin access to it', function(done) {
|
||||
return expect_no_admin_access(
|
||||
this.anon,
|
||||
this.project_id,
|
||||
|
|
|
@ -22,12 +22,12 @@ describe('siteIsOpen', function() {
|
|||
return done()
|
||||
})))
|
||||
|
||||
return describe('when siteIsOpen is false', function() {
|
||||
describe('when siteIsOpen is false', function() {
|
||||
beforeEach(() => (Settings.siteIsOpen = false))
|
||||
|
||||
afterEach(() => (Settings.siteIsOpen = true))
|
||||
|
||||
return it('should return maintenance page', done =>
|
||||
it('should return maintenance page', done =>
|
||||
request.get('/login', function(error, response) {
|
||||
response.statusCode.should.equal(503)
|
||||
return done()
|
||||
|
|
|
@ -44,7 +44,7 @@ describe('Exports', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('exporting a project', function() {
|
||||
describe('exporting a project', function() {
|
||||
beforeEach(function(done) {
|
||||
this.version = Math.floor(Math.random() * 10000)
|
||||
MockProjectHistoryApi.setProjectVersion(this.project_id, this.version)
|
||||
|
@ -101,7 +101,7 @@ describe('Exports', function() {
|
|||
return done()
|
||||
})
|
||||
|
||||
return it('should have returned the export ID provided by v1', function(done) {
|
||||
it('should have returned the export ID provided by v1', function(done) {
|
||||
expect(this.exportResponseBody.export_v1_id).to.equal(this.export_id)
|
||||
return done()
|
||||
})
|
||||
|
|
|
@ -77,7 +77,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
})
|
||||
}) // returns a promise
|
||||
|
||||
return it('should set their features to the upgraded set', function(done) {
|
||||
it('should set their features to the upgraded set', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -102,7 +102,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
})
|
||||
}) // returns a promise
|
||||
|
||||
return it('should set their features to the upgraded set', function(done) {
|
||||
it('should set their features to the upgraded set', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -128,7 +128,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
)
|
||||
}) // returns a promise
|
||||
|
||||
return it('should set their features to the bonus set', function(done) {
|
||||
it('should set their features to the bonus set', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -175,7 +175,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return it('should not set their features if institution is not confirmed', function(done) {
|
||||
it('should not set their features if institution is not confirmed', function(done) {
|
||||
this.affiliationData.institution.confirmed = false
|
||||
MockV1Api.setAffiliations([this.affiliationData])
|
||||
return this.user.confirmEmail(this.email, error => {
|
||||
|
@ -200,7 +200,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
)
|
||||
}) // returns a promise
|
||||
|
||||
return it('should set their features to the bonus set and downgrade the extras', function(done) {
|
||||
it('should set their features to the bonus set and downgrade the extras', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -232,7 +232,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
)
|
||||
}) // returns a promise
|
||||
|
||||
return it('should set their features to the v1 plan', function(done) {
|
||||
it('should set their features to the v1 plan', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -260,7 +260,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
)
|
||||
}) // returns a promise
|
||||
|
||||
return it('should set their features to the best of the v1 plan and bonus features', function(done) {
|
||||
it('should set their features to the best of the v1 plan and bonus features', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -304,7 +304,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should set their features to the best set', function(done) {
|
||||
it('should set their features to the best set', function(done) {
|
||||
return syncUserAndGetFeatures(this.user, (error, features) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -318,7 +318,7 @@ describe('FeatureUpdater.refreshFeatures', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('when the notifyV1Flag is passed', function() {
|
||||
describe('when the notifyV1Flag is passed', function() {
|
||||
beforeEach(function() {
|
||||
return User.update(
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('History', function() {
|
|||
return this.owner.login(done)
|
||||
})
|
||||
|
||||
return describe('zip download of version', function() {
|
||||
describe('zip download of version', function() {
|
||||
it('should stream the zip file of a version', function(done) {
|
||||
return this.owner.createProject(
|
||||
'example-project',
|
||||
|
@ -71,7 +71,7 @@ describe('History', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should return 402 for non-v2-history project', function(done) {
|
||||
it('should return 402 for non-v2-history project', function(done) {
|
||||
return this.owner.createProject('non-v2-project', (error, project_id) => {
|
||||
this.project_id = project_id
|
||||
if (error != null) {
|
||||
|
|
|
@ -93,7 +93,7 @@ describe('Labels', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('deleting a label', function(done) {
|
||||
it('deleting a label', function(done) {
|
||||
const label_id = new ObjectId().toString()
|
||||
const comment = 'a label comment'
|
||||
const version = 3
|
||||
|
|
|
@ -236,7 +236,7 @@ describe('LinkedFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow to create a linked-file with v1 id', function(done) {
|
||||
it('should not allow to create a linked-file with v1 id', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
url: `/project/${this.project_one_id}/linked_file`,
|
||||
|
@ -299,7 +299,7 @@ describe('LinkedFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should refuse to refresh', function(done) {
|
||||
it('should refuse to refresh', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
url: `/project/${this.project_one_id}/linked_file/abcd/refresh`,
|
||||
|
@ -524,7 +524,7 @@ describe('LinkedFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should accept a URL withuot a leading http://, and add it', function(done) {
|
||||
it('should accept a URL withuot a leading http://, and add it', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
url: `/project/${this.project_id}/linked_file`,
|
||||
|
@ -664,7 +664,7 @@ describe('LinkedFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should refresh the file', function(done) {
|
||||
it('should refresh the file', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
url: `/project/${this.project_one_id}/linked_file/${
|
||||
|
@ -694,7 +694,7 @@ describe('LinkedFiles', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('with a linked project_output_file from a v1 project that has not been imported', function() {
|
||||
describe('with a linked project_output_file from a v1 project that has not been imported', function() {
|
||||
before(function(done) {
|
||||
return async.series(
|
||||
[
|
||||
|
@ -734,7 +734,7 @@ describe('LinkedFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should refuse to refresh', function(done) {
|
||||
it('should refuse to refresh', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
url: `/project/${this.project_one_id}/linked_file/abcdef/refresh`,
|
||||
|
|
|
@ -31,7 +31,7 @@ describe('Project CRUD', function() {
|
|||
)
|
||||
}))
|
||||
|
||||
return describe('when project has malformed id', () =>
|
||||
describe('when project has malformed id', () =>
|
||||
it('should return 404', function(done) {
|
||||
return this.user.request.get('/project/blah', function(err, res, body) {
|
||||
expect(res.statusCode).to.equal(404)
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
return (this.callback = sinon.stub())
|
||||
})
|
||||
|
||||
return describe('creating a project from the example template', function() {
|
||||
describe('creating a project from the example template', function() {
|
||||
before(function(done) {
|
||||
return this.owner.createProject(
|
||||
'example-project',
|
||||
|
@ -117,7 +117,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -139,12 +139,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to add a folder with the same name', function() {
|
||||
describe('trying to add a folder with the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -185,7 +185,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -207,12 +207,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to upload a file with the same name', function() {
|
||||
describe('trying to upload a file with the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should succeed (overwriting the file)', function() {
|
||||
it('should succeed (overwriting the file)', function() {
|
||||
return expect(this.body.success).to.equal(true)
|
||||
})
|
||||
})
|
||||
|
@ -268,7 +268,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -290,12 +290,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to upload a file with the same name', function() {
|
||||
describe('trying to upload a file with the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with failure status', function() {
|
||||
it('should respond with failure status', function() {
|
||||
return expect(this.body.success).to.equal(false)
|
||||
})
|
||||
})
|
||||
|
@ -349,7 +349,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -372,12 +372,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to rename a file to the same name', function() {
|
||||
describe('trying to rename a file to the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -395,7 +395,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with failure status', function() {
|
||||
it('should respond with failure status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -420,7 +420,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -443,12 +443,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to rename a file to the same name', function() {
|
||||
describe('trying to rename a file to the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -466,7 +466,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with failure status', function() {
|
||||
it('should respond with failure status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -491,7 +491,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -514,12 +514,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to rename a file to the same name', function() {
|
||||
describe('trying to rename a file to the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -537,13 +537,13 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with failure status', function() {
|
||||
it('should respond with failure status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return describe('for an existing folder with a file with the same name', function() {
|
||||
describe('for an existing folder with a file with the same name', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -612,7 +612,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -635,7 +635,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
@ -658,12 +658,12 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
||||
return describe('trying to move a folder into a subfolder of itself', function() {
|
||||
describe('trying to move a folder into a subfolder of itself', function() {
|
||||
before(function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
|
@ -681,7 +681,7 @@ describe('ProjectDuplicateNames', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should respond with 400 error status', function() {
|
||||
it('should respond with 400 error status', function() {
|
||||
return expect(this.res.statusCode).to.equal(400)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -40,7 +40,7 @@ describe('ProjectFeatures', function() {
|
|||
return async.series([cb => this.owner.login(cb)], done)
|
||||
})
|
||||
|
||||
return describe('with private project', function() {
|
||||
describe('with private project', function() {
|
||||
before(function(done) {
|
||||
return this.owner.createProject(
|
||||
'private-project',
|
||||
|
@ -62,7 +62,7 @@ describe('ProjectFeatures', function() {
|
|||
return this.owner.defaultFeatures(done)
|
||||
})
|
||||
|
||||
return it('should have premium features', function(done) {
|
||||
it('should have premium features', function(done) {
|
||||
return joinProject(this.owner._id, this.project_id, function(
|
||||
error,
|
||||
response,
|
||||
|
@ -77,7 +77,7 @@ describe('ProjectFeatures', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('with an basic account', function() {
|
||||
describe('with an basic account', function() {
|
||||
before(function(done) {
|
||||
return this.owner.downgradeFeatures(done)
|
||||
})
|
||||
|
@ -85,7 +85,7 @@ describe('ProjectFeatures', function() {
|
|||
return this.owner.defaultFeatures(done)
|
||||
})
|
||||
|
||||
return it('should have basic features', function(done) {
|
||||
it('should have basic features', function(done) {
|
||||
return joinProject(this.owner._id, this.project_id, function(
|
||||
error,
|
||||
response,
|
||||
|
|
|
@ -414,7 +414,7 @@ describe('ProjectInviteTests', function() {
|
|||
return done()
|
||||
})
|
||||
|
||||
return describe('creating two invites', function() {
|
||||
describe('creating two invites', function() {
|
||||
beforeEach(function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
|
@ -524,7 +524,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should allow the project owner to create many invites at once', function(done) {
|
||||
it('should allow the project owner to create many invites at once', function(done) {
|
||||
this.inviteOne = null
|
||||
this.inviteTwo = null
|
||||
return Async.series(
|
||||
|
@ -600,7 +600,7 @@ describe('ProjectInviteTests', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('clicking the invite link', function() {
|
||||
describe('clicking the invite link', function() {
|
||||
beforeEach(function(done) {
|
||||
this.projectId = null
|
||||
this.fakeProject = null
|
||||
|
@ -667,7 +667,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('when user clicks on the invite a second time', function() {
|
||||
describe('when user clicks on the invite a second time', function() {
|
||||
it('should just redirect to the project page', function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
|
@ -685,7 +685,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('when the user recieves another invite to the same project', () =>
|
||||
describe('when the user recieves another invite to the same project', () =>
|
||||
it('should redirect to the project page', function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
|
@ -730,7 +730,7 @@ describe('ProjectInviteTests', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('user is not a member of the project', function() {
|
||||
describe('user is not a member of the project', function() {
|
||||
it('should not grant access if the user does not accept the invite', function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
|
@ -758,7 +758,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should allow the user to accept the invite and access the project', function(done) {
|
||||
it('should allow the user to accept the invite and access the project', function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
cb => expectInvitePage(this.user, this.link, cb),
|
||||
|
@ -771,7 +771,7 @@ describe('ProjectInviteTests', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('user is not logged in initially', function() {
|
||||
describe('user is not logged in initially', function() {
|
||||
before(function(done) {
|
||||
return this.user.logout(done)
|
||||
})
|
||||
|
@ -823,7 +823,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should allow user to accept the invite if the user registers a new account', function(done) {
|
||||
it('should allow user to accept the invite if the user registers a new account', function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
cb => expectInviteRedirectToRegister(this.user, this.link, cb),
|
||||
|
@ -858,7 +858,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should display invalid-invite if the user registers a new account', function(done) {
|
||||
it('should display invalid-invite if the user registers a new account', function(done) {
|
||||
const badLink = this.link.replace(
|
||||
this.invite.token,
|
||||
'not_a_real_token'
|
||||
|
@ -909,7 +909,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should allow user to accept the invite if the user registers a new account', function(done) {
|
||||
it('should allow user to accept the invite if the user registers a new account', function(done) {
|
||||
return Async.series(
|
||||
[
|
||||
cb => expectInvitePage(this.user, this.link, cb),
|
||||
|
@ -921,7 +921,7 @@ describe('ProjectInviteTests', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('login workflow with non-valid token', function() {
|
||||
describe('login workflow with non-valid token', function() {
|
||||
before(function(done) {
|
||||
return this.user.logout(done)
|
||||
})
|
||||
|
@ -936,7 +936,7 @@ describe('ProjectInviteTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should show the invalid-invite page once the user has logged in', function(done) {
|
||||
it('should show the invalid-invite page once the user has logged in', function(done) {
|
||||
const badLink = this.link.replace(
|
||||
this.invite.token,
|
||||
'not_a_real_token'
|
||||
|
|
|
@ -110,7 +110,7 @@ describe('ProjectStructureMongoLock', () =>
|
|||
)
|
||||
})
|
||||
|
||||
return it('can get the project if rootFolder is not in the projection', function(done) {
|
||||
it('can get the project if rootFolder is not in the projection', function(done) {
|
||||
return ProjectGetter.getProject(
|
||||
this.locked_project._id,
|
||||
{ _id: true },
|
||||
|
@ -123,7 +123,7 @@ describe('ProjectStructureMongoLock', () =>
|
|||
})
|
||||
})
|
||||
|
||||
return describe('interacting with other projects', function() {
|
||||
describe('interacting with other projects', function() {
|
||||
before(function(done) {
|
||||
return ProjectCreationHandler.createBlankProject(
|
||||
this.user._id,
|
||||
|
@ -151,7 +151,7 @@ describe('ProjectStructureMongoLock', () =>
|
|||
)
|
||||
})
|
||||
|
||||
return it('can get other projects without a projection', function(done) {
|
||||
it('can get other projects without a projection', function(done) {
|
||||
return ProjectGetter.getProject(
|
||||
this.unlocked_project._id,
|
||||
(err, project) => {
|
||||
|
|
|
@ -75,7 +75,7 @@ describe('ProjectStructureChanges', function() {
|
|||
return expect(version).to.equal(3)
|
||||
})
|
||||
|
||||
return it('should version creating a file', function() {
|
||||
it('should version creating a file', function() {
|
||||
const {
|
||||
fileUpdates: updates,
|
||||
version
|
||||
|
@ -129,7 +129,7 @@ describe('ProjectStructureChanges', function() {
|
|||
return expect(version).to.equal(3)
|
||||
})
|
||||
|
||||
return it('should version the files created', function() {
|
||||
it('should version the files created', function() {
|
||||
const {
|
||||
fileUpdates: updates,
|
||||
version
|
||||
|
@ -196,7 +196,7 @@ describe('ProjectStructureChanges', function() {
|
|||
return expect(version).to.equal(this.project_0.version + 1)
|
||||
})
|
||||
|
||||
return it('should increment the project structure version number', function() {
|
||||
it('should increment the project structure version number', function() {
|
||||
return expect(this.project_1.version).to.equal(this.project_0.version + 1)
|
||||
})
|
||||
})
|
||||
|
@ -244,7 +244,7 @@ describe('ProjectStructureChanges', function() {
|
|||
return expect(version).to.equal(2)
|
||||
})
|
||||
|
||||
return it('should version the files created', function() {
|
||||
it('should version the files created', function() {
|
||||
const {
|
||||
fileUpdates: updates,
|
||||
version
|
||||
|
@ -288,7 +288,7 @@ describe('ProjectStructureChanges', function() {
|
|||
))
|
||||
})
|
||||
|
||||
return it('should set the project name from the zip contents', function(done) {
|
||||
it('should set the project name from the zip contents', function(done) {
|
||||
return ProjectGetter.getProject(
|
||||
this.uploaded_project_id,
|
||||
(error, project) => {
|
||||
|
@ -330,7 +330,7 @@ describe('ProjectStructureChanges', function() {
|
|||
))
|
||||
})
|
||||
|
||||
return it('should set the project name from the zip contents', function(done) {
|
||||
it('should set the project name from the zip contents', function(done) {
|
||||
return ProjectGetter.getProject(
|
||||
this.uploaded_project_id,
|
||||
(error, project) => {
|
||||
|
@ -372,7 +372,7 @@ describe('ProjectStructureChanges', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not create the top-level folder', function(done) {
|
||||
it('should not create the top-level folder', function(done) {
|
||||
return ProjectGetter.getProject(this.uploaded_project_id, function(
|
||||
error,
|
||||
project
|
||||
|
@ -415,7 +415,7 @@ describe('ProjectStructureChanges', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should treat the backslash as a directory separator', function(done) {
|
||||
it('should treat the backslash as a directory separator', function(done) {
|
||||
return ProjectGetter.getProject(this.uploaded_project_id, function(
|
||||
error,
|
||||
project
|
||||
|
@ -495,7 +495,7 @@ describe('ProjectStructureChanges', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should correctly parse Greek utf8', function() {
|
||||
it('should correctly parse Greek utf8', function() {
|
||||
const {
|
||||
docUpdates: updates
|
||||
} = MockDocUpdaterApi.getProjectStructureUpdates(this.uploaded_project_id)
|
||||
|
@ -584,7 +584,7 @@ describe('ProjectStructureChanges', function() {
|
|||
))
|
||||
})
|
||||
|
||||
return it('should version a replacement file', function(done) {
|
||||
it('should version a replacement file', function(done) {
|
||||
let req
|
||||
const image_file = fs.createReadStream(
|
||||
Path.resolve(__dirname + '/../files/2pixel.png')
|
||||
|
@ -771,7 +771,7 @@ describe('ProjectStructureChanges', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should version moving a folder', function(done) {
|
||||
it('should version moving a folder', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
uri: `project/${example_project_id}/folder`,
|
||||
|
@ -949,7 +949,7 @@ describe('ProjectStructureChanges', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should version renaming a folder', function(done) {
|
||||
it('should version renaming a folder', function(done) {
|
||||
return this.owner.request.post(
|
||||
{
|
||||
uri: `project/${example_project_id}/Folder/${example_folder_id_1}/rename`,
|
||||
|
@ -1022,7 +1022,7 @@ describe('ProjectStructureChanges', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return it('should version deleting a folder', function(done) {
|
||||
it('should version deleting a folder', function(done) {
|
||||
return this.owner.request.delete(
|
||||
{
|
||||
uri: `project/${example_project_id}/Folder/${example_folder_id_2}`
|
||||
|
@ -1282,7 +1282,7 @@ describe('ProjectStructureChanges', function() {
|
|||
return image_file.pipe(req)
|
||||
})
|
||||
|
||||
return it('should version deleting a doc', function(done) {
|
||||
it('should version deleting a doc', function(done) {
|
||||
let req
|
||||
return (req = this.owner.request.delete(
|
||||
{
|
||||
|
@ -1333,7 +1333,7 @@ describe('ProjectStructureChanges', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('uploading a document', function() {
|
||||
describe('uploading a document', function() {
|
||||
beforeEach(function(done) {
|
||||
MockDocUpdaterApi.clearProjectStructureUpdates()
|
||||
return ProjectGetter.getProject(example_project_id, (error, project) => {
|
||||
|
@ -1346,7 +1346,7 @@ describe('ProjectStructureChanges', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('with an unusual character set', function() {
|
||||
describe('with an unusual character set', function() {
|
||||
it('should correctly handle utf16-le data', function(done) {
|
||||
let req
|
||||
const document_file = fs.createReadStream(
|
||||
|
@ -1394,7 +1394,7 @@ describe('ProjectStructureChanges', function() {
|
|||
))
|
||||
})
|
||||
|
||||
return it('should correctly handle windows1252/iso-8859-1/latin1 data', function(done) {
|
||||
it('should correctly handle windows1252/iso-8859-1/latin1 data', function(done) {
|
||||
let req
|
||||
const document_file = fs.createReadStream(
|
||||
Path.resolve(
|
||||
|
|
|
@ -66,7 +66,7 @@ describe('ProxyUrls', function() {
|
|||
done
|
||||
))
|
||||
|
||||
return it('handle missing baseUrl', done =>
|
||||
it('handle missing baseUrl', done =>
|
||||
async.series(
|
||||
[cb => assertResponse('/proxy/missing/baseUrl', 500, null, cb)],
|
||||
done
|
||||
|
|
|
@ -86,7 +86,7 @@ describe('RedirectUrls', function() {
|
|||
}
|
||||
))
|
||||
|
||||
return it('redirects to /sign_in_to_v1 with authWithV1 setting', done =>
|
||||
it('redirects to /sign_in_to_v1 with authWithV1 setting', done =>
|
||||
assertRedirect(
|
||||
'get',
|
||||
'/docs_v1?zip_uri=http%3A%2F%2Foverleaf.test%2Ffoo%3Fbar%3Dbaz%26qux%3Dthing&bar=baz',
|
||||
|
|
|
@ -83,7 +83,7 @@ describe('LoginRateLimit', function() {
|
|||
return (this.badPassword = 'badpassword')
|
||||
})
|
||||
|
||||
return it('should rate limit login attempts after 10 within two minutes', function(done) {
|
||||
it('should rate limit login attempts after 10 within two minutes', function(done) {
|
||||
return this.user.request.get('/login', (err, res, body) => {
|
||||
return async.timesSeries(
|
||||
15,
|
||||
|
@ -193,7 +193,7 @@ describe('CSRF protection', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return it('should fail with a stale csrf token', function(done) {
|
||||
it('should fail with a stale csrf token', function(done) {
|
||||
return this.user.request.get('/login', (err, res, body) => {
|
||||
return this.user.getCsrfToken(error => {
|
||||
const oldCsrfToken = this.user.csrfToken
|
||||
|
@ -225,7 +225,7 @@ describe('Register', function() {
|
|||
return (this.user = new User())
|
||||
})
|
||||
|
||||
return it('Set emails attribute', function(done) {
|
||||
it('Set emails attribute', function(done) {
|
||||
return this.user.register((error, user) => {
|
||||
expect(error).to.not.exist
|
||||
user.email.should.equal(this.user.email)
|
||||
|
@ -255,7 +255,7 @@ describe('Register with bonus referal id', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('Adds a referal when an id is supplied and the referal source is "bonus"', function(done) {
|
||||
it('Adds a referal when an id is supplied and the referal source is "bonus"', function(done) {
|
||||
return this.user1.get((error, user) => {
|
||||
expect(error).to.not.exist
|
||||
user.refered_user_count.should.eql(1)
|
||||
|
@ -284,7 +284,7 @@ describe('LoginViaRegistration', function() {
|
|||
return (this.project_id = null)
|
||||
})
|
||||
|
||||
return describe('[Security] Trying to register/login as another user', function() {
|
||||
describe('[Security] Trying to register/login as another user', function() {
|
||||
it('should not allow sign in with secondary email', function(done) {
|
||||
const secondaryEmail = 'acceptance-test-secondary@example.com'
|
||||
return this.user1.addEmail(secondaryEmail, err => {
|
||||
|
@ -336,7 +336,7 @@ describe('LoginViaRegistration', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should still ensure user2 cannot access the project', function(done) {
|
||||
it('should still ensure user2 cannot access the project', function(done) {
|
||||
return expectNoProjectAccess(this.user2, this.project_id, done)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -88,7 +88,7 @@ describe('RestoringFiles', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return it('should have restored the doc', function(done) {
|
||||
it('should have restored the doc', function(done) {
|
||||
return this.owner.getProject(this.project_id, (error, project) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -110,7 +110,7 @@ describe('RestoringFiles', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('restoring from v2 history', function() {
|
||||
describe('restoring from v2 history', function() {
|
||||
describe('restoring a text file', function() {
|
||||
beforeEach(function(done) {
|
||||
MockProjectHistoryApi.addOldFile(
|
||||
|
@ -138,7 +138,7 @@ describe('RestoringFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have created a doc', function(done) {
|
||||
it('should have created a doc', function(done) {
|
||||
return this.owner.getProject(this.project_id, (error, project) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -185,7 +185,7 @@ describe('RestoringFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have created a file', function(done) {
|
||||
it('should have created a file', function(done) {
|
||||
return this.owner.getProject(this.project_id, (error, project) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -242,7 +242,7 @@ describe('RestoringFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have created the doc in the named folder', function(done) {
|
||||
it('should have created the doc in the named folder', function(done) {
|
||||
return this.owner.getProject(this.project_id, (error, project) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -286,7 +286,7 @@ describe('RestoringFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have created the folder and restored the doc to it', function(done) {
|
||||
it('should have created the folder and restored the doc to it', function(done) {
|
||||
return this.owner.getProject(this.project_id, (error, project) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
@ -304,7 +304,7 @@ describe('RestoringFiles', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('restoring to a filename that already exists', function() {
|
||||
describe('restoring to a filename that already exists', function() {
|
||||
beforeEach(function(done) {
|
||||
MockProjectHistoryApi.addOldFile(
|
||||
this.project_id,
|
||||
|
@ -331,7 +331,7 @@ describe('RestoringFiles', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have created the doc in the root folder', function(done) {
|
||||
it('should have created the doc in the root folder', function(done) {
|
||||
return this.owner.getProject(this.project_id, (error, project) => {
|
||||
if (error != null) {
|
||||
throw error
|
||||
|
|
|
@ -81,7 +81,7 @@ describe('SecurityHeaders', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have cache headers on project page', function(done) {
|
||||
it('should have cache headers on project page', function(done) {
|
||||
return async.series(
|
||||
[
|
||||
cb => this.user.login(cb),
|
||||
|
|
|
@ -89,7 +89,7 @@ describe('Sessions', function() {
|
|||
return (this.user2.password = this.user1.password)
|
||||
})
|
||||
|
||||
return it('should have two sessions in UserSessions set', function(done) {
|
||||
it('should have two sessions in UserSessions set', function(done) {
|
||||
return async.series(
|
||||
[
|
||||
next => {
|
||||
|
@ -212,7 +212,7 @@ describe('Sessions', function() {
|
|||
return (this.user3.password = this.user1.password)
|
||||
})
|
||||
|
||||
return it('should erase both sessions when password is reset', function(done) {
|
||||
it('should erase both sessions when password is reset', function(done) {
|
||||
return async.series(
|
||||
[
|
||||
next => {
|
||||
|
@ -320,7 +320,7 @@ describe('Sessions', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('three sessions, sessions page', function() {
|
||||
describe('three sessions, sessions page', function() {
|
||||
before(function(done) {
|
||||
// set up second session for this user
|
||||
this.user2 = new User()
|
||||
|
@ -338,7 +338,7 @@ describe('Sessions', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should allow the user to erase the other two sessions', function(done) {
|
||||
it('should allow the user to erase the other two sessions', function(done) {
|
||||
return async.series(
|
||||
[
|
||||
next => {
|
||||
|
|
|
@ -48,7 +48,7 @@ describe('SettingsPage', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return it('update main email address', function(done) {
|
||||
it('update main email address', function(done) {
|
||||
const newEmail = 'foo@bar.com'
|
||||
return this.user.updateSettings({ email: newEmail }, error => {
|
||||
should.not.exist(error)
|
||||
|
|
|
@ -45,7 +45,7 @@ describe('Subscriptions', function() {
|
|||
return expect(this.data.personalSubscription).to.equal(null)
|
||||
})
|
||||
|
||||
return it('should return no memberGroupSubscriptions', function() {
|
||||
it('should return no memberGroupSubscriptions', function() {
|
||||
return expect(this.data.memberGroupSubscriptions).to.deep.equal([])
|
||||
})
|
||||
})
|
||||
|
@ -135,7 +135,7 @@ describe('Subscriptions', function() {
|
|||
return expect(this.data.memberGroupSubscriptions).to.deep.equal([])
|
||||
})
|
||||
|
||||
return it('should include redeemed coupons', function(done) {
|
||||
it('should include redeemed coupons', function(done) {
|
||||
MockRecurlyApi.redemptions['mock-account-id'] = [
|
||||
{ state: 'active', coupon_code: 'test-coupon-1' },
|
||||
{ state: 'inactive', coupon_code: 'test-coupon-2' },
|
||||
|
@ -209,7 +209,7 @@ describe('Subscriptions', function() {
|
|||
return expect(subscription.recurly).to.not.exist
|
||||
})
|
||||
|
||||
return it('should return no memberGroupSubscriptions', function() {
|
||||
it('should return no memberGroupSubscriptions', function() {
|
||||
return expect(this.data.memberGroupSubscriptions).to.deep.equal([])
|
||||
})
|
||||
})
|
||||
|
@ -286,7 +286,7 @@ describe('Subscriptions', function() {
|
|||
return expect(this.data.personalSubscription).to.equal(null)
|
||||
})
|
||||
|
||||
return it('should return the two memberGroupSubscriptions', function() {
|
||||
it('should return the two memberGroupSubscriptions', function() {
|
||||
expect(this.data.memberGroupSubscriptions.length).to.equal(2)
|
||||
expect(
|
||||
// Mongoose populates the admin_id with the user
|
||||
|
@ -348,7 +348,7 @@ describe('Subscriptions', function() {
|
|||
return expect(this.data.personalSubscription).to.equal(null)
|
||||
})
|
||||
|
||||
return it('should return the managedGroupSubscriptions', function() {
|
||||
it('should return the managedGroupSubscriptions', function() {
|
||||
expect(this.data.managedGroupSubscriptions.length).to.equal(1)
|
||||
const subscription = this.data.managedGroupSubscriptions[0]
|
||||
expect(
|
||||
|
@ -401,7 +401,7 @@ describe('Subscriptions', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should return the managedInstitutions', function() {
|
||||
it('should return the managedInstitutions', function() {
|
||||
expect(this.data.managedInstitutions.length).to.equal(1)
|
||||
const institution = this.data.managedInstitutions[0]
|
||||
expect(institution.v1Id).to.equal(this.v1Id)
|
||||
|
@ -492,14 +492,14 @@ describe('Subscriptions', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should return only the affilations with confirmed institutions, and confirmed emails', function() {
|
||||
it('should return only the affilations with confirmed institutions, and confirmed emails', function() {
|
||||
return expect(this.data.confirmedMemberInstitutions).to.deep.equal([
|
||||
{ name: 'Stanford', licence: 'pro_plus', confirmed: true }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
return describe('when the user has a v1 subscription', function() {
|
||||
describe('when the user has a v1 subscription', function() {
|
||||
before(function(done) {
|
||||
let v1Id
|
||||
MockV1Api.setUser((v1Id = MockV1Api.nextV1Id()), {
|
||||
|
@ -543,7 +543,7 @@ describe('Subscriptions', function() {
|
|||
return expect(this.data.memberGroupSubscriptions).to.deep.equal([])
|
||||
})
|
||||
|
||||
return it('should return a v1SubscriptionStatus', function() {
|
||||
it('should return a v1SubscriptionStatus', function() {
|
||||
return expect(this.data.v1SubscriptionStatus).to.deep.equal(
|
||||
this.subscription_status
|
||||
)
|
||||
|
@ -551,7 +551,7 @@ describe('Subscriptions', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('canceling', function() {
|
||||
describe('canceling', function() {
|
||||
before(function(done) {
|
||||
let v1Id
|
||||
this.user = new User()
|
||||
|
@ -580,7 +580,7 @@ describe('Subscriptions', function() {
|
|||
return expect(this.v1_user.canceled).to.equal(true)
|
||||
})
|
||||
|
||||
return it('should redirect to the subscription dashboard', function() {
|
||||
it('should redirect to the subscription dashboard', function() {
|
||||
expect(this.response.statusCode).to.equal(302)
|
||||
return expect(this.response.headers.location).to.equal(
|
||||
'/user/subscription'
|
||||
|
|
|
@ -198,7 +198,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow the user to join the project', function(done) {
|
||||
it('should not allow the user to join the project', function(done) {
|
||||
return try_content_access(
|
||||
this.other1,
|
||||
this.project_id,
|
||||
|
@ -269,7 +269,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('made private again', function() {
|
||||
describe('made private again', function() {
|
||||
before(function(done) {
|
||||
return this.owner.makePrivate(this.project_id, () =>
|
||||
setTimeout(done, 1000)
|
||||
|
@ -299,7 +299,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow the user to join the project', function(done) {
|
||||
it('should not allow the user to join the project', function(done) {
|
||||
return try_content_access(
|
||||
this.other1,
|
||||
this.project_id,
|
||||
|
@ -372,7 +372,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('made private again', function() {
|
||||
describe('made private again', function() {
|
||||
before(function(done) {
|
||||
return this.owner.makePrivate(this.project_id, () =>
|
||||
setTimeout(done, 1000)
|
||||
|
@ -402,7 +402,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow the user to join the project', function(done) {
|
||||
it('should not allow the user to join the project', function(done) {
|
||||
return try_anon_content_access(
|
||||
this.anon,
|
||||
this.project_id,
|
||||
|
@ -476,7 +476,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('made private again', function() {
|
||||
describe('made private again', function() {
|
||||
before(function(done) {
|
||||
return this.owner.makePrivate(this.project_id, () =>
|
||||
setTimeout(done, 1000)
|
||||
|
@ -506,7 +506,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow the user to join the project', function(done) {
|
||||
it('should not allow the user to join the project', function(done) {
|
||||
return try_content_access(
|
||||
this.other1,
|
||||
this.project_id,
|
||||
|
@ -569,7 +569,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow the user to join the project', function(done) {
|
||||
it('should not allow the user to join the project', function(done) {
|
||||
return try_anon_content_access(
|
||||
this.anon,
|
||||
this.project_id,
|
||||
|
@ -642,7 +642,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('made private again', function() {
|
||||
describe('made private again', function() {
|
||||
before(function(done) {
|
||||
return this.owner.makePrivate(this.project_id, () =>
|
||||
setTimeout(done, 1000)
|
||||
|
@ -672,7 +672,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow the user to join the project', function(done) {
|
||||
it('should not allow the user to join the project', function(done) {
|
||||
return try_anon_content_access(
|
||||
this.anon,
|
||||
this.project_id,
|
||||
|
@ -748,7 +748,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow other user to join the project', function(done) {
|
||||
it('should not allow other user to join the project', function(done) {
|
||||
return try_content_access(
|
||||
this.other2,
|
||||
this.project_id,
|
||||
|
@ -838,7 +838,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow a different user to join the project', function(done) {
|
||||
it('should not allow a different user to join the project', function(done) {
|
||||
return try_content_access(
|
||||
this.other2,
|
||||
this.project_id,
|
||||
|
@ -870,7 +870,7 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should redirect read only token to v1', function(done) {
|
||||
it('should redirect read only token to v1', function(done) {
|
||||
const unimportedV1Token = 'abcd'
|
||||
return try_read_only_token_access(
|
||||
this.owner,
|
||||
|
@ -886,7 +886,7 @@ describe('TokenAccess', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('importing v1 project', function() {
|
||||
describe('importing v1 project', function() {
|
||||
before(function(done) {
|
||||
settings.projectImportingCheckMaxCreateDelta = 3600
|
||||
settings.overleaf = { host: 'http://localhost:5000' }
|
||||
|
@ -960,10 +960,10 @@ describe('TokenAccess', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return describe('when importing check not configured', function() {
|
||||
describe('when importing check not configured', function() {
|
||||
before(() => delete settings.projectImportingCheckMaxCreateDelta)
|
||||
|
||||
return it('should load editor', function(done) {
|
||||
it('should load editor', function(done) {
|
||||
return try_read_and_write_token_access(
|
||||
this.owner,
|
||||
this.tokens.readAndWrite,
|
||||
|
|
|
@ -37,7 +37,7 @@ describe('TpdsUpdateTests', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('deleting a file', function() {
|
||||
describe('deleting a file', function() {
|
||||
before(function(done) {
|
||||
return request(
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ describe('TpdsUpdateTests', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should have deleted the file', function(done) {
|
||||
it('should have deleted the file', function(done) {
|
||||
return ProjectGetter.getProject(this.project_id, function(
|
||||
error,
|
||||
project
|
||||
|
|
|
@ -127,7 +127,7 @@ describe('UserEmails', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should not allow confirmation of the email if the user has changed', function(done) {
|
||||
it('should not allow confirmation of the email if the user has changed', function(done) {
|
||||
let token1 = null
|
||||
let token2 = null
|
||||
this.user2 = new User()
|
||||
|
@ -472,7 +472,7 @@ describe('UserEmails', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it("should not allow reconfirmation if the email doesn't match the user", function(done) {
|
||||
it("should not allow reconfirmation if the email doesn't match the user", function(done) {
|
||||
return async.series(
|
||||
[
|
||||
cb => {
|
||||
|
@ -512,7 +512,7 @@ describe('UserEmails', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('setting a default email', function() {
|
||||
describe('setting a default email', function() {
|
||||
it('should update confirmed emails for users not in v1', function(done) {
|
||||
const token = null
|
||||
return async.series(
|
||||
|
@ -736,7 +736,7 @@ describe('UserEmails', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should return an error if the email exists in v1', function(done) {
|
||||
it('should return an error if the email exists in v1', function(done) {
|
||||
MockV1Api.existingEmails.push('exists-in-v1@example.com')
|
||||
return async.series(
|
||||
[
|
||||
|
|
|
@ -38,7 +38,7 @@ describe('User Must Reconfirm', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('Requesting reconfirmation email', function() {
|
||||
describe('Requesting reconfirmation email', function() {
|
||||
it('should return a success to client for existing account', function(done) {
|
||||
return this.user.reconfirmAccountRequest(
|
||||
this.user.email,
|
||||
|
@ -50,7 +50,7 @@ describe('User Must Reconfirm', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should return a 404 to client for non-existent account', function(done) {
|
||||
it('should return a 404 to client for non-existent account', function(done) {
|
||||
return this.user.reconfirmAccountRequest(
|
||||
'fake@overleaf.com',
|
||||
(err, response) => {
|
||||
|
|
|
@ -56,7 +56,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should merge external data', function(done) {
|
||||
it('should merge external data', function(done) {
|
||||
this.externalData = {
|
||||
test: 'different',
|
||||
another: 'key'
|
||||
|
@ -76,7 +76,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('when third party identity does not exists', () =>
|
||||
describe('when third party identity does not exists', () =>
|
||||
it('should return error', function(done) {
|
||||
ThirdPartyIdentityManager.login(
|
||||
this.provider,
|
||||
|
@ -105,7 +105,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
)
|
||||
}))
|
||||
|
||||
return describe('when provider is already linked', function() {
|
||||
describe('when provider is already linked', function() {
|
||||
beforeEach(function(done) {
|
||||
return ThirdPartyIdentityManager.link(
|
||||
this.user.id,
|
||||
|
@ -144,7 +144,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should replace existing data', function(done) {
|
||||
it('should replace existing data', function(done) {
|
||||
this.externalData = { replace: 'data' }
|
||||
return ThirdPartyIdentityManager.link(
|
||||
this.user.id,
|
||||
|
@ -164,7 +164,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
})
|
||||
})
|
||||
|
||||
return describe('unlink', function() {
|
||||
describe('unlink', function() {
|
||||
describe('when provider not already linked', () =>
|
||||
it('should succeed', function(done) {
|
||||
return ThirdPartyIdentityManager.unlink(
|
||||
|
@ -178,7 +178,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
)
|
||||
}))
|
||||
|
||||
return describe('when provider is already linked', function() {
|
||||
describe('when provider is already linked', function() {
|
||||
beforeEach(function(done) {
|
||||
return ThirdPartyIdentityManager.link(
|
||||
this.user.id,
|
||||
|
@ -189,7 +189,7 @@ describe('ThirdPartyIdentityManager', function() {
|
|||
)
|
||||
})
|
||||
|
||||
return it('should remove thirdPartyIdentifiers entry', function(done) {
|
||||
it('should remove thirdPartyIdentifiers entry', function(done) {
|
||||
return ThirdPartyIdentityManager.unlink(
|
||||
this.user.id,
|
||||
this.provider,
|
||||
|
|
|
@ -198,7 +198,7 @@ curl -H "X-Forwarded-Proto: https" -v ${buildUrl(
|
|||
})
|
||||
})
|
||||
|
||||
return it('the project list', function(done) {
|
||||
it('the project list', function(done) {
|
||||
logger.log('smoke test: Checking can load project list')
|
||||
this.timeout(4000)
|
||||
const command = `\
|
||||
|
|
|
@ -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]
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue