From 735f7bd51ef42013ca48600196d5783088e869f7 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 16 Feb 2016 12:28:02 +0000 Subject: [PATCH] change res.send to res.sendStatus for new express --- .../ReferencesSearchController.coffee | 6 +-- .../ReferencesSearchControllerTests.coffee | 44 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee b/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee index 96f06228c8..11cef82553 100644 --- a/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee +++ b/services/web/app/coffee/Features/ReferencesSearch/ReferencesSearchController.coffee @@ -12,12 +12,12 @@ module.exports = ReferencesSearchController = docIds = req.body.docIds if (!docIds or !(docIds instanceof Array)) logger.err {projectId, docIds}, "docIds is not valid, should be either Array or String 'ALL'" - return res.send 400 + return res.sendStatus 400 logger.log {projectId, docIds: docIds}, "index references for project" ReferencesSearchHandler.index projectId, docIds, (err, data) -> if err logger.err {err, projectId}, "error indexing all references" - return res.send 500 + return res.sendStatus 500 ReferencesSearchController._handleIndexResponse(req, res, projectId, shouldBroadcast, data) indexAll: (req, res) -> @@ -27,7 +27,7 @@ module.exports = ReferencesSearchController = ReferencesSearchHandler.indexAll projectId, (err, data) -> if err logger.err {err, projectId}, "error indexing all references" - return res.send 500 + return res.sendStatus 500 ReferencesSearchController._handleIndexResponse(req, res, projectId, shouldBroadcast, data) _handleIndexResponse: (req, res, projectId, shouldBroadcast, data) -> diff --git a/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee b/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee index 9b12648520..cdc959427e 100644 --- a/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee +++ b/services/web/test/UnitTests/coffee/ReferencesSearch/ReferencesSearchControllerTests.coffee @@ -32,7 +32,7 @@ describe "ReferencesSearchController", -> shouldBroadcast: false @res = new MockResponse() @res.json = sinon.stub() - @res.send = sinon.stub() + @res.sendStatus = sinon.stub() @fakeResponseData = projectId: @projectId, keys: ['one', 'two', 'three'] @@ -48,9 +48,9 @@ describe "ReferencesSearchController", -> it 'should not produce an error', (done) -> @call () => - @res.send.callCount.should.equal 0 - @res.send.calledWith(500).should.equal false - @res.send.calledWith(400).should.equal false + @res.sendStatus.callCount.should.equal 0 + @res.sendStatus.calledWith(500).should.equal false + @res.sendStatus.calledWith(400).should.equal false done() it 'should return data', (done) -> @@ -78,9 +78,9 @@ describe "ReferencesSearchController", -> it 'should not produce an error', (done) -> @call () => - @res.send.callCount.should.equal 0 - @res.send.calledWith(500).should.equal false - @res.send.calledWith(400).should.equal false + @res.sendStatus.callCount.should.equal 0 + @res.sendStatus.calledWith(500).should.equal false + @res.sendStatus.calledWith(400).should.equal false done() it 'should still return data', (done) -> @@ -102,9 +102,9 @@ describe "ReferencesSearchController", -> it 'should not produce an error', (done) -> @call () => - @res.send.callCount.should.equal 0 - @res.send.calledWith(500).should.equal false - @res.send.calledWith(400).should.equal false + @res.sendStatus.callCount.should.equal 0 + @res.sendStatus.calledWith(500).should.equal false + @res.sendStatus.calledWith(400).should.equal false done() it 'should still return data', (done) -> @@ -138,9 +138,9 @@ describe "ReferencesSearchController", -> it 'should not produce an error', (done) -> @call () => - @res.send.callCount.should.equal 0 - @res.send.calledWith(500).should.equal false - @res.send.calledWith(400).should.equal false + @res.sendStatus.callCount.should.equal 0 + @res.sendStatus.calledWith(500).should.equal false + @res.sendStatus.calledWith(400).should.equal false done() it 'should not call EditorRealTimController.emitToRoom', (done) -> @@ -155,8 +155,8 @@ describe "ReferencesSearchController", -> it 'should produce an error response', (done) -> @call () => - @res.send.callCount.should.equal 1 - @res.send.calledWith(500).should.equal true + @res.sendStatus.callCount.should.equal 1 + @res.sendStatus.calledWith(500).should.equal true done() describe 'when shouldBroadcast is true', -> @@ -172,9 +172,9 @@ describe "ReferencesSearchController", -> it 'should not produce an error', (done) -> @call () => - @res.send.callCount.should.equal 0 - @res.send.calledWith(500).should.equal false - @res.send.calledWith(400).should.equal false + @res.sendStatus.callCount.should.equal 0 + @res.sendStatus.calledWith(500).should.equal false + @res.sendStatus.calledWith(400).should.equal false done() it 'should still return data', (done) -> @@ -190,8 +190,8 @@ describe "ReferencesSearchController", -> it 'should produce an error response', (done) -> @call () => - @res.send.callCount.should.equal 1 - @res.send.calledWith(400).should.equal true + @res.sendStatus.callCount.should.equal 1 + @res.sendStatus.calledWith(400).should.equal true done() it 'should not call ReferencesSearchHandler.index', (done) -> @@ -206,8 +206,8 @@ describe "ReferencesSearchController", -> it 'should produce an error response', (done) -> @call () => - @res.send.callCount.should.equal 1 - @res.send.calledWith(400).should.equal true + @res.sendStatus.callCount.should.equal 1 + @res.sendStatus.calledWith(400).should.equal true done() it 'should not call ReferencesSearchHandler.index', (done) ->