|
@@ -6,7 +6,6 @@
|
|
|
// Fix any style issues and re-enable lint.
|
|
// Fix any style issues and re-enable lint.
|
|
|
/*
|
|
/*
|
|
|
* decaffeinate suggestions:
|
|
* decaffeinate suggestions:
|
|
|
- * DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
* DS206: Consider reworking classes to avoid initClass
|
|
* DS206: Consider reworking classes to avoid initClass
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
*/
|
|
*/
|
|
@@ -46,11 +45,11 @@ describe('HttpController', function () {
|
|
|
this.project_id = 'project-id-123'
|
|
this.project_id = 'project-id-123'
|
|
|
this.doc_id = 'doc-id-123'
|
|
this.doc_id = 'doc-id-123'
|
|
|
this.next = sinon.stub()
|
|
this.next = sinon.stub()
|
|
|
- return (this.res = {
|
|
|
|
|
|
|
+ this.res = {
|
|
|
send: sinon.stub(),
|
|
send: sinon.stub(),
|
|
|
sendStatus: sinon.stub(),
|
|
sendStatus: sinon.stub(),
|
|
|
json: sinon.stub()
|
|
json: sinon.stub()
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('getDoc', function () {
|
|
describe('getDoc', function () {
|
|
@@ -61,12 +60,12 @@ describe('HttpController', function () {
|
|
|
this.fromVersion = 42
|
|
this.fromVersion = 42
|
|
|
this.ranges = { changes: 'mock', comments: 'mock' }
|
|
this.ranges = { changes: 'mock', comments: 'mock' }
|
|
|
this.pathname = '/a/b/c'
|
|
this.pathname = '/a/b/c'
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
|
doc_id: this.doc_id
|
|
doc_id: this.doc_id
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('when the document exists and no recent ops are requested', function () {
|
|
describe('when the document exists and no recent ops are requested', function () {
|
|
@@ -82,17 +81,17 @@ describe('HttpController', function () {
|
|
|
this.ranges,
|
|
this.ranges,
|
|
|
this.pathname
|
|
this.pathname
|
|
|
)
|
|
)
|
|
|
- return this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should get the doc', function () {
|
|
it('should get the doc', function () {
|
|
|
- return this.DocumentManager.getDocAndRecentOpsWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.getDocAndRecentOpsWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, -1)
|
|
.calledWith(this.project_id, this.doc_id, -1)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return the doc as JSON', function () {
|
|
it('should return the doc as JSON', function () {
|
|
|
- return this.res.json
|
|
|
|
|
|
|
+ this.res.json
|
|
|
.calledWith({
|
|
.calledWith({
|
|
|
id: this.doc_id,
|
|
id: this.doc_id,
|
|
|
lines: this.lines,
|
|
lines: this.lines,
|
|
@@ -105,7 +104,7 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
|
'getting doc via http'
|
|
'getting doc via http'
|
|
@@ -113,8 +112,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -132,17 +131,17 @@ describe('HttpController', function () {
|
|
|
this.pathname
|
|
this.pathname
|
|
|
)
|
|
)
|
|
|
this.req.query = { fromVersion: `${this.fromVersion}` }
|
|
this.req.query = { fromVersion: `${this.fromVersion}` }
|
|
|
- return this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should get the doc', function () {
|
|
it('should get the doc', function () {
|
|
|
- return this.DocumentManager.getDocAndRecentOpsWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.getDocAndRecentOpsWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, this.fromVersion)
|
|
.calledWith(this.project_id, this.doc_id, this.fromVersion)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return the doc as JSON', function () {
|
|
it('should return the doc as JSON', function () {
|
|
|
- return this.res.json
|
|
|
|
|
|
|
+ this.res.json
|
|
|
.calledWith({
|
|
.calledWith({
|
|
|
id: this.doc_id,
|
|
id: this.doc_id,
|
|
|
lines: this.lines,
|
|
lines: this.lines,
|
|
@@ -155,7 +154,7 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
|
'getting doc via http'
|
|
'getting doc via http'
|
|
@@ -163,8 +162,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -173,26 +172,26 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.getDocAndRecentOpsWithLock = sinon
|
|
this.DocumentManager.getDocAndRecentOpsWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, null, null, null)
|
|
.callsArgWith(3, null, null, null)
|
|
|
- return this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with NotFoundError', function () {
|
|
|
|
|
- return this.next
|
|
|
|
|
|
|
+ it('should call next with NotFoundError', function () {
|
|
|
|
|
+ this.next
|
|
|
.calledWith(new Errors.NotFoundError('not found'))
|
|
.calledWith(new Errors.NotFoundError('not found'))
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.DocumentManager.getDocAndRecentOpsWithLock = sinon
|
|
this.DocumentManager.getDocAndRecentOpsWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, new Error('oops'), null, null)
|
|
.callsArgWith(3, new Error('oops'), null, null)
|
|
|
- return this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.getDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -202,7 +201,7 @@ describe('HttpController', function () {
|
|
|
this.lines = ['one', 'two', 'three']
|
|
this.lines = ['one', 'two', 'three']
|
|
|
this.source = 'dropbox'
|
|
this.source = 'dropbox'
|
|
|
this.user_id = 'user-id-123'
|
|
this.user_id = 'user-id-123'
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
headers: {},
|
|
headers: {},
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
@@ -214,17 +213,17 @@ describe('HttpController', function () {
|
|
|
user_id: this.user_id,
|
|
user_id: this.user_id,
|
|
|
undoing: (this.undoing = true)
|
|
undoing: (this.undoing = true)
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.DocumentManager.setDocWithLock = sinon.stub().callsArgWith(6)
|
|
this.DocumentManager.setDocWithLock = sinon.stub().callsArgWith(6)
|
|
|
- return this.HttpController.setDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.setDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should set the doc', function () {
|
|
it('should set the doc', function () {
|
|
|
- return this.DocumentManager.setDocWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.setDocWithLock
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
this.project_id,
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
this.doc_id,
|
|
@@ -237,11 +236,11 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{
|
|
{
|
|
|
doc_id: this.doc_id,
|
|
doc_id: this.doc_id,
|
|
@@ -256,8 +255,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -266,15 +265,15 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.setDocWithLock = sinon
|
|
this.DocumentManager.setDocWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(6, new Error('oops'))
|
|
.callsArgWith(6, new Error('oops'))
|
|
|
- return this.HttpController.setDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.setDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when the payload is too large', function () {
|
|
|
|
|
|
|
+ describe('when the payload is too large', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
const lines = []
|
|
const lines = []
|
|
|
for (let _ = 0; _ <= 200000; _++) {
|
|
for (let _ = 0; _ <= 200000; _++) {
|
|
@@ -282,46 +281,46 @@ describe('HttpController', function () {
|
|
|
}
|
|
}
|
|
|
this.req.body.lines = lines
|
|
this.req.body.lines = lines
|
|
|
this.DocumentManager.setDocWithLock = sinon.stub().callsArgWith(6)
|
|
this.DocumentManager.setDocWithLock = sinon.stub().callsArgWith(6)
|
|
|
- return this.HttpController.setDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.setDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should send back a 406 response', function () {
|
|
it('should send back a 406 response', function () {
|
|
|
- return this.res.sendStatus.calledWith(406).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(406).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should not call setDocWithLock', function () {
|
|
|
|
|
- return this.DocumentManager.setDocWithLock.callCount.should.equal(0)
|
|
|
|
|
|
|
+ it('should not call setDocWithLock', function () {
|
|
|
|
|
+ this.DocumentManager.setDocWithLock.callCount.should.equal(0)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('flushProject', function () {
|
|
describe('flushProject', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id
|
|
project_id: this.project_id
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.ProjectManager.flushProjectWithLocks = sinon.stub().callsArgWith(1)
|
|
this.ProjectManager.flushProjectWithLocks = sinon.stub().callsArgWith(1)
|
|
|
- return this.HttpController.flushProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.flushProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should flush the project', function () {
|
|
it('should flush the project', function () {
|
|
|
- return this.ProjectManager.flushProjectWithLocks
|
|
|
|
|
|
|
+ this.ProjectManager.flushProjectWithLocks
|
|
|
.calledWith(this.project_id)
|
|
.calledWith(this.project_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ project_id: this.project_id },
|
|
{ project_id: this.project_id },
|
|
|
'flushing project via http'
|
|
'flushing project via http'
|
|
@@ -329,21 +328,21 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.ProjectManager.flushProjectWithLocks = sinon
|
|
this.ProjectManager.flushProjectWithLocks = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(1, new Error('oops'))
|
|
.callsArgWith(1, new Error('oops'))
|
|
|
- return this.HttpController.flushProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.flushProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -352,12 +351,12 @@ describe('HttpController', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.lines = ['one', 'two', 'three']
|
|
this.lines = ['one', 'two', 'three']
|
|
|
this.version = 42
|
|
this.version = 42
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
|
doc_id: this.doc_id
|
|
doc_id: this.doc_id
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
@@ -365,25 +364,21 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.flushDocIfLoadedWithLock = sinon
|
|
this.DocumentManager.flushDocIfLoadedWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(2)
|
|
.callsArgWith(2)
|
|
|
- return this.HttpController.flushDocIfLoaded(
|
|
|
|
|
- this.req,
|
|
|
|
|
- this.res,
|
|
|
|
|
- this.next
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.HttpController.flushDocIfLoaded(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should flush the doc', function () {
|
|
it('should flush the doc', function () {
|
|
|
- return this.DocumentManager.flushDocIfLoadedWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.flushDocIfLoadedWithLock
|
|
|
.calledWith(this.project_id, this.doc_id)
|
|
.calledWith(this.project_id, this.doc_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
|
'flushing doc via http'
|
|
'flushing doc via http'
|
|
@@ -391,38 +386,34 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.DocumentManager.flushDocIfLoadedWithLock = sinon
|
|
this.DocumentManager.flushDocIfLoadedWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(2, new Error('oops'))
|
|
.callsArgWith(2, new Error('oops'))
|
|
|
- return this.HttpController.flushDocIfLoaded(
|
|
|
|
|
- this.req,
|
|
|
|
|
- this.res,
|
|
|
|
|
- this.next
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.HttpController.flushDocIfLoaded(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('deleteDoc', function () {
|
|
describe('deleteDoc', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
|
doc_id: this.doc_id
|
|
doc_id: this.doc_id
|
|
|
},
|
|
},
|
|
|
query: {}
|
|
query: {}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
@@ -430,11 +421,11 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.flushAndDeleteDocWithLock = sinon
|
|
this.DocumentManager.flushAndDeleteDocWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3)
|
|
.callsArgWith(3)
|
|
|
- return this.HttpController.deleteDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should flush and delete the doc', function () {
|
|
it('should flush and delete the doc', function () {
|
|
|
- return this.DocumentManager.flushAndDeleteDocWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.flushAndDeleteDocWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, {
|
|
.calledWith(this.project_id, this.doc_id, {
|
|
|
ignoreFlushErrors: false
|
|
ignoreFlushErrors: false
|
|
|
})
|
|
})
|
|
@@ -442,17 +433,17 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should flush project history', function () {
|
|
it('should flush project history', function () {
|
|
|
- return this.HistoryManager.flushProjectChangesAsync
|
|
|
|
|
|
|
+ this.HistoryManager.flushProjectChangesAsync
|
|
|
.calledWithExactly(this.project_id)
|
|
.calledWithExactly(this.project_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
{ doc_id: this.doc_id, project_id: this.project_id },
|
|
|
'deleting doc via http'
|
|
'deleting doc via http'
|
|
@@ -460,8 +451,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -469,47 +460,47 @@ describe('HttpController', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.req.query.ignore_flush_errors = 'true'
|
|
this.req.query.ignore_flush_errors = 'true'
|
|
|
this.DocumentManager.flushAndDeleteDocWithLock = sinon.stub().yields()
|
|
this.DocumentManager.flushAndDeleteDocWithLock = sinon.stub().yields()
|
|
|
- return this.HttpController.deleteDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should delete the doc', function () {
|
|
it('should delete the doc', function () {
|
|
|
- return this.DocumentManager.flushAndDeleteDocWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.flushAndDeleteDocWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, { ignoreFlushErrors: true })
|
|
.calledWith(this.project_id, this.doc_id, { ignoreFlushErrors: true })
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return a successful No Content response', function () {
|
|
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ it('should return a successful No Content response', function () {
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.DocumentManager.flushAndDeleteDocWithLock = sinon
|
|
this.DocumentManager.flushAndDeleteDocWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, new Error('oops'))
|
|
.callsArgWith(3, new Error('oops'))
|
|
|
- return this.HttpController.deleteDoc(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteDoc(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should flush project history', function () {
|
|
it('should flush project history', function () {
|
|
|
- return this.HistoryManager.flushProjectChangesAsync
|
|
|
|
|
|
|
+ this.HistoryManager.flushProjectChangesAsync
|
|
|
.calledWithExactly(this.project_id)
|
|
.calledWithExactly(this.project_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('deleteProject', function () {
|
|
describe('deleteProject', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id
|
|
project_id: this.project_id
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
@@ -517,21 +508,21 @@ describe('HttpController', function () {
|
|
|
this.ProjectManager.flushAndDeleteProjectWithLocks = sinon
|
|
this.ProjectManager.flushAndDeleteProjectWithLocks = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(2)
|
|
.callsArgWith(2)
|
|
|
- return this.HttpController.deleteProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should delete the project', function () {
|
|
it('should delete the project', function () {
|
|
|
- return this.ProjectManager.flushAndDeleteProjectWithLocks
|
|
|
|
|
|
|
+ this.ProjectManager.flushAndDeleteProjectWithLocks
|
|
|
.calledWith(this.project_id)
|
|
.calledWith(this.project_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ project_id: this.project_id },
|
|
{ project_id: this.project_id },
|
|
|
'deleting project via http'
|
|
'deleting project via http'
|
|
@@ -539,8 +530,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -550,39 +541,39 @@ describe('HttpController', function () {
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(1)
|
|
.callsArgWith(1)
|
|
|
this.req.query = { background: true, shutdown: true }
|
|
this.req.query = { background: true, shutdown: true }
|
|
|
- return this.HttpController.deleteProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should queue the flush and delete', function () {
|
|
|
|
|
- return this.ProjectManager.queueFlushAndDeleteProject
|
|
|
|
|
|
|
+ it('should queue the flush and delete', function () {
|
|
|
|
|
+ this.ProjectManager.queueFlushAndDeleteProject
|
|
|
.calledWith(this.project_id)
|
|
.calledWith(this.project_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.ProjectManager.flushAndDeleteProjectWithLocks = sinon
|
|
this.ProjectManager.flushAndDeleteProjectWithLocks = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(2, new Error('oops'))
|
|
.callsArgWith(2, new Error('oops'))
|
|
|
- return this.HttpController.deleteProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('acceptChanges', function () {
|
|
describe('acceptChanges', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
|
doc_id: this.doc_id,
|
|
doc_id: this.doc_id,
|
|
|
change_id: (this.change_id = 'mock-change-od-1')
|
|
change_id: (this.change_id = 'mock-change-od-1')
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully with a single change', function () {
|
|
describe('successfully with a single change', function () {
|
|
@@ -590,21 +581,21 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.acceptChangesWithLock = sinon
|
|
this.DocumentManager.acceptChangesWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3)
|
|
.callsArgWith(3)
|
|
|
- return this.HttpController.acceptChanges(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.acceptChanges(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should accept the change', function () {
|
|
it('should accept the change', function () {
|
|
|
- return this.DocumentManager.acceptChangesWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.acceptChangesWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, [this.change_id])
|
|
.calledWith(this.project_id, this.doc_id, [this.change_id])
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ project_id: this.project_id, doc_id: this.doc_id },
|
|
{ project_id: this.project_id, doc_id: this.doc_id },
|
|
|
'accepting 1 changes via http'
|
|
'accepting 1 changes via http'
|
|
@@ -612,8 +603,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -629,17 +620,17 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.acceptChangesWithLock = sinon
|
|
this.DocumentManager.acceptChangesWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3)
|
|
.callsArgWith(3)
|
|
|
- return this.HttpController.acceptChanges(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.acceptChanges(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should accept the changes in the body payload', function () {
|
|
it('should accept the changes in the body payload', function () {
|
|
|
- return this.DocumentManager.acceptChangesWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.acceptChangesWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, this.change_ids)
|
|
.calledWith(this.project_id, this.doc_id, this.change_ids)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should log the request with the correct number of changes', function () {
|
|
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ it('should log the request with the correct number of changes', function () {
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ project_id: this.project_id, doc_id: this.doc_id },
|
|
{ project_id: this.project_id, doc_id: this.doc_id },
|
|
|
`accepting ${this.change_ids.length} changes via http`
|
|
`accepting ${this.change_ids.length} changes via http`
|
|
@@ -648,29 +639,29 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.DocumentManager.acceptChangesWithLock = sinon
|
|
this.DocumentManager.acceptChangesWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, new Error('oops'))
|
|
.callsArgWith(3, new Error('oops'))
|
|
|
- return this.HttpController.acceptChanges(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.acceptChanges(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('deleteComment', function () {
|
|
describe('deleteComment', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
|
doc_id: this.doc_id,
|
|
doc_id: this.doc_id,
|
|
|
comment_id: (this.comment_id = 'mock-comment-id')
|
|
comment_id: (this.comment_id = 'mock-comment-id')
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
@@ -678,21 +669,21 @@ describe('HttpController', function () {
|
|
|
this.DocumentManager.deleteCommentWithLock = sinon
|
|
this.DocumentManager.deleteCommentWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3)
|
|
.callsArgWith(3)
|
|
|
- return this.HttpController.deleteComment(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteComment(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should accept the change', function () {
|
|
it('should accept the change', function () {
|
|
|
- return this.DocumentManager.deleteCommentWithLock
|
|
|
|
|
|
|
+ this.DocumentManager.deleteCommentWithLock
|
|
|
.calledWith(this.project_id, this.doc_id, this.comment_id)
|
|
.calledWith(this.project_id, this.doc_id, this.comment_id)
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{
|
|
{
|
|
|
project_id: this.project_id,
|
|
project_id: this.project_id,
|
|
@@ -704,21 +695,21 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.DocumentManager.deleteCommentWithLock = sinon
|
|
this.DocumentManager.deleteCommentWithLock = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, new Error('oops'))
|
|
.callsArgWith(3, new Error('oops'))
|
|
|
- return this.HttpController.deleteComment(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.deleteComment(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -730,14 +721,14 @@ describe('HttpController', function () {
|
|
|
{ _id: '1234', lines: 'hello', v: 23 },
|
|
{ _id: '1234', lines: 'hello', v: 23 },
|
|
|
{ _id: '4567', lines: 'world', v: 45 }
|
|
{ _id: '4567', lines: 'world', v: 45 }
|
|
|
]
|
|
]
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id
|
|
project_id: this.project_id
|
|
|
},
|
|
},
|
|
|
query: {
|
|
query: {
|
|
|
state: this.state
|
|
state: this.state
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
@@ -745,7 +736,7 @@ describe('HttpController', function () {
|
|
|
this.ProjectManager.getProjectDocsAndFlushIfOld = sinon
|
|
this.ProjectManager.getProjectDocsAndFlushIfOld = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, null, this.docs)
|
|
.callsArgWith(3, null, this.docs)
|
|
|
- return this.HttpController.getProjectDocsAndFlushIfOld(
|
|
|
|
|
|
|
+ this.HttpController.getProjectDocsAndFlushIfOld(
|
|
|
this.req,
|
|
this.req,
|
|
|
this.res,
|
|
this.res,
|
|
|
this.next
|
|
this.next
|
|
@@ -753,17 +744,17 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should get docs from the project manager', function () {
|
|
it('should get docs from the project manager', function () {
|
|
|
- return this.ProjectManager.getProjectDocsAndFlushIfOld
|
|
|
|
|
|
|
+ this.ProjectManager.getProjectDocsAndFlushIfOld
|
|
|
.calledWith(this.project_id, this.state, {})
|
|
.calledWith(this.project_id, this.state, {})
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful response', function () {
|
|
it('should return a successful response', function () {
|
|
|
- return this.res.send.calledWith(this.docs).should.equal(true)
|
|
|
|
|
|
|
+ this.res.send.calledWith(this.docs).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the request', function () {
|
|
it('should log the request', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ project_id: this.project_id, exclude: [] },
|
|
{ project_id: this.project_id, exclude: [] },
|
|
|
'getting docs via http'
|
|
'getting docs via http'
|
|
@@ -772,7 +763,7 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should log the response', function () {
|
|
it('should log the response', function () {
|
|
|
- return this.logger.log
|
|
|
|
|
|
|
+ this.logger.log
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
{ project_id: this.project_id, result: ['1234:23', '4567:45'] },
|
|
{ project_id: this.project_id, result: ['1234:23', '4567:45'] },
|
|
|
'got docs via http'
|
|
'got docs via http'
|
|
@@ -780,8 +771,8 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -793,32 +784,32 @@ describe('HttpController', function () {
|
|
|
3,
|
|
3,
|
|
|
new Errors.ProjectStateChangedError('project state changed')
|
|
new Errors.ProjectStateChangedError('project state changed')
|
|
|
)
|
|
)
|
|
|
- return this.HttpController.getProjectDocsAndFlushIfOld(
|
|
|
|
|
|
|
+ this.HttpController.getProjectDocsAndFlushIfOld(
|
|
|
this.req,
|
|
this.req,
|
|
|
this.res,
|
|
this.res,
|
|
|
this.next
|
|
this.next
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return an HTTP 409 Conflict response', function () {
|
|
|
|
|
- return this.res.sendStatus.calledWith(409).should.equal(true)
|
|
|
|
|
|
|
+ it('should return an HTTP 409 Conflict response', function () {
|
|
|
|
|
+ this.res.sendStatus.calledWith(409).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an error occurs', function () {
|
|
|
|
|
|
|
+ describe('when an error occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.ProjectManager.getProjectDocsAndFlushIfOld = sinon
|
|
this.ProjectManager.getProjectDocsAndFlushIfOld = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(3, new Error('oops'))
|
|
.callsArgWith(3, new Error('oops'))
|
|
|
- return this.HttpController.getProjectDocsAndFlushIfOld(
|
|
|
|
|
|
|
+ this.HttpController.getProjectDocsAndFlushIfOld(
|
|
|
this.req,
|
|
this.req,
|
|
|
this.res,
|
|
this.res,
|
|
|
this.next
|
|
this.next
|
|
|
)
|
|
)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
@@ -830,7 +821,7 @@ describe('HttpController', function () {
|
|
|
this.docUpdates = sinon.stub()
|
|
this.docUpdates = sinon.stub()
|
|
|
this.fileUpdates = sinon.stub()
|
|
this.fileUpdates = sinon.stub()
|
|
|
this.version = 1234567
|
|
this.version = 1234567
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
body: {
|
|
body: {
|
|
|
projectHistoryId: this.projectHistoryId,
|
|
projectHistoryId: this.projectHistoryId,
|
|
|
userId: this.userId,
|
|
userId: this.userId,
|
|
@@ -841,7 +832,7 @@ describe('HttpController', function () {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id
|
|
project_id: this.project_id
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
@@ -849,11 +840,11 @@ describe('HttpController', function () {
|
|
|
this.ProjectManager.updateProjectWithLocks = sinon
|
|
this.ProjectManager.updateProjectWithLocks = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(6)
|
|
.callsArgWith(6)
|
|
|
- return this.HttpController.updateProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.updateProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should accept the change', function () {
|
|
it('should accept the change', function () {
|
|
|
- return this.ProjectManager.updateProjectWithLocks
|
|
|
|
|
|
|
+ this.ProjectManager.updateProjectWithLocks
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
this.project_id,
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
this.projectHistoryId,
|
|
@@ -866,35 +857,35 @@ describe('HttpController', function () {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return a successful No Content response', function () {
|
|
it('should return a successful No Content response', function () {
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should time the request', function () {
|
|
|
|
|
- return this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
|
|
|
|
+ it('should time the request', function () {
|
|
|
|
|
+ this.Metrics.Timer.prototype.done.called.should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.ProjectManager.updateProjectWithLocks = sinon
|
|
this.ProjectManager.updateProjectWithLocks = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(6, new Error('oops'))
|
|
.callsArgWith(6, new Error('oops'))
|
|
|
- return this.HttpController.updateProject(this.req, this.res, this.next)
|
|
|
|
|
|
|
+ this.HttpController.updateProject(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('resyncProjectHistory', function () {
|
|
|
|
|
|
|
+ describe('resyncProjectHistory', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.projectHistoryId = 'history-id-123'
|
|
this.projectHistoryId = 'history-id-123'
|
|
|
this.docs = sinon.stub()
|
|
this.docs = sinon.stub()
|
|
|
this.files = sinon.stub()
|
|
this.files = sinon.stub()
|
|
|
this.fileUpdates = sinon.stub()
|
|
this.fileUpdates = sinon.stub()
|
|
|
- return (this.req = {
|
|
|
|
|
|
|
+ this.req = {
|
|
|
body: {
|
|
body: {
|
|
|
projectHistoryId: this.projectHistoryId,
|
|
projectHistoryId: this.projectHistoryId,
|
|
|
docs: this.docs,
|
|
docs: this.docs,
|
|
@@ -903,21 +894,17 @@ describe('HttpController', function () {
|
|
|
params: {
|
|
params: {
|
|
|
project_id: this.project_id
|
|
project_id: this.project_id
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('successfully', function () {
|
|
describe('successfully', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.HistoryManager.resyncProjectHistory = sinon.stub().callsArgWith(4)
|
|
this.HistoryManager.resyncProjectHistory = sinon.stub().callsArgWith(4)
|
|
|
- return this.HttpController.resyncProjectHistory(
|
|
|
|
|
- this.req,
|
|
|
|
|
- this.res,
|
|
|
|
|
- this.next
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.HttpController.resyncProjectHistory(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should accept the change', function () {
|
|
it('should accept the change', function () {
|
|
|
- return this.HistoryManager.resyncProjectHistory
|
|
|
|
|
|
|
+ this.HistoryManager.resyncProjectHistory
|
|
|
.calledWith(
|
|
.calledWith(
|
|
|
this.project_id,
|
|
this.project_id,
|
|
|
this.projectHistoryId,
|
|
this.projectHistoryId,
|
|
@@ -927,25 +914,21 @@ describe('HttpController', function () {
|
|
|
.should.equal(true)
|
|
.should.equal(true)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should return a successful No Content response', function () {
|
|
|
|
|
- return this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
|
|
|
|
+ it('should return a successful No Content response', function () {
|
|
|
|
|
+ this.res.sendStatus.calledWith(204).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return describe('when an errors occurs', function () {
|
|
|
|
|
|
|
+ describe('when an errors occurs', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.HistoryManager.resyncProjectHistory = sinon
|
|
this.HistoryManager.resyncProjectHistory = sinon
|
|
|
.stub()
|
|
.stub()
|
|
|
.callsArgWith(4, new Error('oops'))
|
|
.callsArgWith(4, new Error('oops'))
|
|
|
- return this.HttpController.resyncProjectHistory(
|
|
|
|
|
- this.req,
|
|
|
|
|
- this.res,
|
|
|
|
|
- this.next
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ this.HttpController.resyncProjectHistory(this.req, this.res, this.next)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- return it('should call next with the error', function () {
|
|
|
|
|
- return this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
|
|
|
|
+ it('should call next with the error', function () {
|
|
|
|
|
+ this.next.calledWith(new Error('oops')).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|