From 608b1dd65781744c48bdd14eb95aa4d4328a692e Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 12 May 2015 11:40:29 +0100 Subject: [PATCH] replace deprecated send(code,body) calls --- services/clsi/app.coffee | 4 ++-- services/clsi/app/coffee/CompileController.coffee | 4 ++-- .../test/unit/coffee/CompileControllerTests.coffee | 13 +++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/services/clsi/app.coffee b/services/clsi/app.coffee index 42c5c062dd..9083bb4bf3 100644 --- a/services/clsi/app.coffee +++ b/services/clsi/app.coffee @@ -84,7 +84,7 @@ if Settings.smokeTest app.get "/health_check", (req, res)-> res.contentType(resCacher?.setContentType) - res.send resCacher?.code, resCacher?.body + res.status(resCacher?.code).send(resCacher?.body) profiler = require "v8-profiler" app.get "/profile", (req, res) -> @@ -101,7 +101,7 @@ app.get "/heapdump", (req, res)-> app.use (error, req, res, next) -> logger.error err: error, "server error" - res.send error?.statusCode || 500 + res.sendStatus(error?.statusCode || 500) app.listen port = (Settings.internal?.clsi?.port or 3013), host = (Settings.internal?.clsi?.host or "localhost"), (error) -> logger.info "CLSI starting up, listening on #{host}:#{port}" diff --git a/services/clsi/app/coffee/CompileController.coffee b/services/clsi/app/coffee/CompileController.coffee index 29373c36db..71368be737 100644 --- a/services/clsi/app/coffee/CompileController.coffee +++ b/services/clsi/app/coffee/CompileController.coffee @@ -28,7 +28,7 @@ module.exports = CompileController = status = "success" timer.done() - res.send (code or 200), { + res.status(code or 200).send { compile: status: status error: error?.message or error @@ -41,7 +41,7 @@ module.exports = CompileController = clearCache: (req, res, next = (error) ->) -> ProjectPersistenceManager.clearProject req.params.project_id, (error) -> return next(error) if error? - res.send 204 # No content + res.sendStatus(204) # No content syncFromCode: (req, res, next = (error) ->) -> file = req.query.file diff --git a/services/clsi/test/unit/coffee/CompileControllerTests.coffee b/services/clsi/test/unit/coffee/CompileControllerTests.coffee index bc2d988132..3298f472e6 100644 --- a/services/clsi/test/unit/coffee/CompileControllerTests.coffee +++ b/services/clsi/test/unit/coffee/CompileControllerTests.coffee @@ -44,6 +44,7 @@ describe "CompileController", -> }] @RequestParser.parse = sinon.stub().callsArgWith(1, null, @request) @ProjectPersistenceManager.markProjectAsJustAccessed = sinon.stub().callsArg(1) + @res.status = sinon.stub().returnsThis() @res.send = sinon.stub() describe "successfully", -> @@ -67,8 +68,9 @@ describe "CompileController", -> .should.equal true it "should return the JSON response", -> + @res.status.calledWith(200).should.equal true @res.send - .calledWith(200, + .calledWith( compile: status: "success" error: null @@ -85,8 +87,9 @@ describe "CompileController", -> @CompileController.compile @req, @res it "should return the JSON response with the error", -> + @res.status.calledWith(500).should.equal true @res.send - .calledWith(500, + .calledWith( compile: status: "error" error: @message @@ -102,8 +105,9 @@ describe "CompileController", -> @CompileController.compile @req, @res it "should return the JSON response with the timeout status", -> + @res.status.calledWith(200).should.equal true @res.send - .calledWith(200, + .calledWith( compile: status: "timedout" error: @message @@ -117,8 +121,9 @@ describe "CompileController", -> @CompileController.compile @req, @res it "should return the JSON response with the failure status", -> + @res.status.calledWith(200).should.equal true @res.send - .calledWith(200, + .calledWith( compile: error: null status: "failure"