diff --git a/services/document-updater/test/unit/js/HttpController/HttpControllerTests.js b/services/document-updater/test/unit/js/HttpController/HttpControllerTests.js index 8f4125fcfa..18c74691bc 100644 --- a/services/document-updater/test/unit/js/HttpController/HttpControllerTests.js +++ b/services/document-updater/test/unit/js/HttpController/HttpControllerTests.js @@ -6,7 +6,6 @@ // Fix any style issues and re-enable lint. /* * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns * DS206: Consider reworking classes to avoid initClass * 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.doc_id = 'doc-id-123' this.next = sinon.stub() - return (this.res = { + this.res = { send: sinon.stub(), sendStatus: sinon.stub(), json: sinon.stub() - }) + } }) describe('getDoc', function () { @@ -61,12 +60,12 @@ describe('HttpController', function () { this.fromVersion = 42 this.ranges = { changes: 'mock', comments: 'mock' } this.pathname = '/a/b/c' - return (this.req = { + this.req = { params: { project_id: this.project_id, doc_id: this.doc_id } - }) + } }) describe('when the document exists and no recent ops are requested', function () { @@ -82,17 +81,17 @@ describe('HttpController', function () { this.ranges, 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 () { - return this.DocumentManager.getDocAndRecentOpsWithLock + this.DocumentManager.getDocAndRecentOpsWithLock .calledWith(this.project_id, this.doc_id, -1) .should.equal(true) }) it('should return the doc as JSON', function () { - return this.res.json + this.res.json .calledWith({ id: this.doc_id, lines: this.lines, @@ -105,7 +104,7 @@ describe('HttpController', function () { }) it('should log the request', function () { - return this.logger.log + this.logger.log .calledWith( { doc_id: this.doc_id, project_id: this.project_id }, 'getting doc via http' @@ -113,8 +112,8 @@ describe('HttpController', function () { .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.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 () { - return this.DocumentManager.getDocAndRecentOpsWithLock + this.DocumentManager.getDocAndRecentOpsWithLock .calledWith(this.project_id, this.doc_id, this.fromVersion) .should.equal(true) }) it('should return the doc as JSON', function () { - return this.res.json + this.res.json .calledWith({ id: this.doc_id, lines: this.lines, @@ -155,7 +154,7 @@ describe('HttpController', function () { }) it('should log the request', function () { - return this.logger.log + this.logger.log .calledWith( { doc_id: this.doc_id, project_id: this.project_id }, 'getting doc via http' @@ -163,8 +162,8 @@ describe('HttpController', function () { .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 .stub() .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')) .should.equal(true) }) }) - return describe('when an errors occurs', function () { + describe('when an errors occurs', function () { beforeEach(function () { this.DocumentManager.getDocAndRecentOpsWithLock = sinon .stub() .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.source = 'dropbox' this.user_id = 'user-id-123' - return (this.req = { + this.req = { headers: {}, params: { project_id: this.project_id, @@ -214,17 +213,17 @@ describe('HttpController', function () { user_id: this.user_id, undoing: (this.undoing = true) } - }) + } }) describe('successfully', function () { beforeEach(function () { 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 () { - return this.DocumentManager.setDocWithLock + this.DocumentManager.setDocWithLock .calledWith( this.project_id, this.doc_id, @@ -237,11 +236,11 @@ describe('HttpController', 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 () { - return this.logger.log + this.logger.log .calledWith( { doc_id: this.doc_id, @@ -256,8 +255,8 @@ describe('HttpController', function () { .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 .stub() .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 () { const lines = [] for (let _ = 0; _ <= 200000; _++) { @@ -282,46 +281,46 @@ describe('HttpController', function () { } this.req.body.lines = lines 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 () { - 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 () { beforeEach(function () { - return (this.req = { + this.req = { params: { project_id: this.project_id } - }) + } }) describe('successfully', function () { beforeEach(function () { 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 () { - return this.ProjectManager.flushProjectWithLocks + this.ProjectManager.flushProjectWithLocks .calledWith(this.project_id) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { project_id: this.project_id }, 'flushing project via http' @@ -329,21 +328,21 @@ describe('HttpController', function () { .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 () { this.ProjectManager.flushProjectWithLocks = sinon .stub() .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 () { this.lines = ['one', 'two', 'three'] this.version = 42 - return (this.req = { + this.req = { params: { project_id: this.project_id, doc_id: this.doc_id } - }) + } }) describe('successfully', function () { @@ -365,25 +364,21 @@ describe('HttpController', function () { this.DocumentManager.flushDocIfLoadedWithLock = sinon .stub() .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 () { - return this.DocumentManager.flushDocIfLoadedWithLock + this.DocumentManager.flushDocIfLoadedWithLock .calledWith(this.project_id, this.doc_id) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { doc_id: this.doc_id, project_id: this.project_id }, 'flushing doc via http' @@ -391,38 +386,34 @@ describe('HttpController', function () { .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 () { this.DocumentManager.flushDocIfLoadedWithLock = sinon .stub() .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 () { beforeEach(function () { - return (this.req = { + this.req = { params: { project_id: this.project_id, doc_id: this.doc_id }, query: {} - }) + } }) describe('successfully', function () { @@ -430,11 +421,11 @@ describe('HttpController', function () { this.DocumentManager.flushAndDeleteDocWithLock = sinon .stub() .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 () { - return this.DocumentManager.flushAndDeleteDocWithLock + this.DocumentManager.flushAndDeleteDocWithLock .calledWith(this.project_id, this.doc_id, { ignoreFlushErrors: false }) @@ -442,17 +433,17 @@ describe('HttpController', function () { }) it('should flush project history', function () { - return this.HistoryManager.flushProjectChangesAsync + this.HistoryManager.flushProjectChangesAsync .calledWithExactly(this.project_id) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { doc_id: this.doc_id, project_id: this.project_id }, 'deleting doc via http' @@ -460,8 +451,8 @@ describe('HttpController', function () { .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 () { this.req.query.ignore_flush_errors = 'true' 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 () { - return this.DocumentManager.flushAndDeleteDocWithLock + this.DocumentManager.flushAndDeleteDocWithLock .calledWith(this.project_id, this.doc_id, { ignoreFlushErrors: 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 () { this.DocumentManager.flushAndDeleteDocWithLock = sinon .stub() .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 () { - return this.HistoryManager.flushProjectChangesAsync + this.HistoryManager.flushProjectChangesAsync .calledWithExactly(this.project_id) .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 () { beforeEach(function () { - return (this.req = { + this.req = { params: { project_id: this.project_id } - }) + } }) describe('successfully', function () { @@ -517,21 +508,21 @@ describe('HttpController', function () { this.ProjectManager.flushAndDeleteProjectWithLocks = sinon .stub() .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 () { - return this.ProjectManager.flushAndDeleteProjectWithLocks + this.ProjectManager.flushAndDeleteProjectWithLocks .calledWith(this.project_id) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { project_id: this.project_id }, 'deleting project via http' @@ -539,8 +530,8 @@ describe('HttpController', function () { .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() .callsArgWith(1) 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) .should.equal(true) }) }) - return describe('when an errors occurs', function () { + describe('when an errors occurs', function () { beforeEach(function () { this.ProjectManager.flushAndDeleteProjectWithLocks = sinon .stub() .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 () { beforeEach(function () { - return (this.req = { + this.req = { params: { project_id: this.project_id, doc_id: this.doc_id, change_id: (this.change_id = 'mock-change-od-1') } - }) + } }) describe('successfully with a single change', function () { @@ -590,21 +581,21 @@ describe('HttpController', function () { this.DocumentManager.acceptChangesWithLock = sinon .stub() .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 () { - return this.DocumentManager.acceptChangesWithLock + this.DocumentManager.acceptChangesWithLock .calledWith(this.project_id, this.doc_id, [this.change_id]) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { project_id: this.project_id, doc_id: this.doc_id }, 'accepting 1 changes via http' @@ -612,8 +603,8 @@ describe('HttpController', function () { .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 .stub() .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 () { - return this.DocumentManager.acceptChangesWithLock + this.DocumentManager.acceptChangesWithLock .calledWith(this.project_id, this.doc_id, this.change_ids) .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( { project_id: this.project_id, doc_id: this.doc_id }, `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 () { this.DocumentManager.acceptChangesWithLock = sinon .stub() .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 () { beforeEach(function () { - return (this.req = { + this.req = { params: { project_id: this.project_id, doc_id: this.doc_id, comment_id: (this.comment_id = 'mock-comment-id') } - }) + } }) describe('successfully', function () { @@ -678,21 +669,21 @@ describe('HttpController', function () { this.DocumentManager.deleteCommentWithLock = sinon .stub() .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 () { - return this.DocumentManager.deleteCommentWithLock + this.DocumentManager.deleteCommentWithLock .calledWith(this.project_id, this.doc_id, this.comment_id) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { project_id: this.project_id, @@ -704,21 +695,21 @@ describe('HttpController', function () { .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 () { this.DocumentManager.deleteCommentWithLock = sinon .stub() .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: '4567', lines: 'world', v: 45 } ] - return (this.req = { + this.req = { params: { project_id: this.project_id }, query: { state: this.state } - }) + } }) describe('successfully', function () { @@ -745,7 +736,7 @@ describe('HttpController', function () { this.ProjectManager.getProjectDocsAndFlushIfOld = sinon .stub() .callsArgWith(3, null, this.docs) - return this.HttpController.getProjectDocsAndFlushIfOld( + this.HttpController.getProjectDocsAndFlushIfOld( this.req, this.res, this.next @@ -753,17 +744,17 @@ describe('HttpController', function () { }) it('should get docs from the project manager', function () { - return this.ProjectManager.getProjectDocsAndFlushIfOld + this.ProjectManager.getProjectDocsAndFlushIfOld .calledWith(this.project_id, this.state, {}) .should.equal(true) }) 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 () { - return this.logger.log + this.logger.log .calledWith( { project_id: this.project_id, exclude: [] }, 'getting docs via http' @@ -772,7 +763,7 @@ describe('HttpController', function () { }) it('should log the response', function () { - return this.logger.log + this.logger.log .calledWith( { project_id: this.project_id, result: ['1234:23', '4567:45'] }, 'got docs via http' @@ -780,8 +771,8 @@ describe('HttpController', function () { .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, new Errors.ProjectStateChangedError('project state changed') ) - return this.HttpController.getProjectDocsAndFlushIfOld( + this.HttpController.getProjectDocsAndFlushIfOld( this.req, this.res, 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 () { this.ProjectManager.getProjectDocsAndFlushIfOld = sinon .stub() .callsArgWith(3, new Error('oops')) - return this.HttpController.getProjectDocsAndFlushIfOld( + this.HttpController.getProjectDocsAndFlushIfOld( 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) }) }) }) @@ -830,7 +821,7 @@ describe('HttpController', function () { this.docUpdates = sinon.stub() this.fileUpdates = sinon.stub() this.version = 1234567 - return (this.req = { + this.req = { body: { projectHistoryId: this.projectHistoryId, userId: this.userId, @@ -841,7 +832,7 @@ describe('HttpController', function () { params: { project_id: this.project_id } - }) + } }) describe('successfully', function () { @@ -849,11 +840,11 @@ describe('HttpController', function () { this.ProjectManager.updateProjectWithLocks = sinon .stub() .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 () { - return this.ProjectManager.updateProjectWithLocks + this.ProjectManager.updateProjectWithLocks .calledWith( this.project_id, this.projectHistoryId, @@ -866,35 +857,35 @@ describe('HttpController', 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 () { this.ProjectManager.updateProjectWithLocks = sinon .stub() .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 () { this.projectHistoryId = 'history-id-123' this.docs = sinon.stub() this.files = sinon.stub() this.fileUpdates = sinon.stub() - return (this.req = { + this.req = { body: { projectHistoryId: this.projectHistoryId, docs: this.docs, @@ -903,21 +894,17 @@ describe('HttpController', function () { params: { project_id: this.project_id } - }) + } }) describe('successfully', function () { beforeEach(function () { 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 () { - return this.HistoryManager.resyncProjectHistory + this.HistoryManager.resyncProjectHistory .calledWith( this.project_id, this.projectHistoryId, @@ -927,25 +914,21 @@ describe('HttpController', function () { .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 () { this.HistoryManager.resyncProjectHistory = sinon .stub() .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) }) }) })