From 47e16df196b9f528b1bc60a84873a169665dc3a0 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Tue, 3 Feb 2015 21:44:59 +0000 Subject: [PATCH] Node v0.12 & io.js support. fixes #4811, refs #4240 - Add v0.12 to the build - Fix express tests to work with iojs/0.12 - Add iojs-v1.2.0 to the build matrix --- .travis.yml | 2 ++ core/server/ghost-server.js | 3 +- core/test/unit/error_handling_spec.js | 44 +++++++++++++++------------ package.json | 9 +++--- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec0e7232f3b..d24f4c676a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,8 @@ language: node_js node_js: - "0.10" + - "0.12" + - "iojs-v1.2.0" sudo: false cache: directories: diff --git a/core/server/ghost-server.js b/core/server/ghost-server.js index 42e150094e3..8a74417ce80 100644 --- a/core/server/ghost-server.js +++ b/core/server/ghost-server.js @@ -46,7 +46,8 @@ GhostServer.prototype.closeConnections = function () { GhostServer.prototype.logStartMessages = function () { // Tell users if their node version is not supported, and exit - if (!semver.satisfies(process.versions.node, packageInfo.engines.node)) { + if (!semver.satisfies(process.versions.node, packageInfo.engines.node) && + !semver.satisfies(process.versions.node, packageInfo.engines.iojs)) { console.log( '\nERROR: Unsupported version of Node'.red, '\nGhost needs Node version'.red, diff --git a/core/test/unit/error_handling_spec.js b/core/test/unit/error_handling_spec.js index 597e013c2e4..b513433736c 100644 --- a/core/test/unit/error_handling_spec.js +++ b/core/test/unit/error_handling_spec.js @@ -326,11 +326,6 @@ describe('Error handling', function () { options.code.should.equal(404); this.statusCode.should.equal(404); - // Test that the headers are correct - this._headers['cache-control'].should.equal( - 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' - ); - done(); }); @@ -339,6 +334,12 @@ describe('Error handling', function () { return res; }); + sandbox.stub(res, 'set', function (value) { + // Test that the headers are correct + value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); + return res; + }); + errors.error404(req, res, done); }); @@ -356,11 +357,6 @@ describe('Error handling', function () { options.code.should.equal(404); this.statusCode.should.equal(404); - // Test that the headers are correct - this._headers['cache-control'].should.equal( - 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' - ); - done(); }); @@ -369,6 +365,12 @@ describe('Error handling', function () { return res; }); + sandbox.stub(res, 'set', function (value) { + // Test that the headers are correct + value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); + return res; + }); + err.status = 404; errors.error500(err, req, res, null); }); @@ -387,14 +389,15 @@ describe('Error handling', function () { options.code.should.equal(500); this.statusCode.should.equal(500); - // Test that the headers are correct - this._headers['cache-control'].should.equal( - 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' - ); - done(); }); + sandbox.stub(res, 'set', function (value) { + // Test that the headers are correct + value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); + return res; + }); + sandbox.stub(express.response, 'status', function (status) { res.statusCode = status; return res; @@ -417,11 +420,6 @@ describe('Error handling', function () { options.code.should.equal(500); this.statusCode.should.equal(500); - // Test that the headers are correct - this._headers['cache-control'].should.equal( - 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' - ); - done(); }); @@ -430,6 +428,12 @@ describe('Error handling', function () { return res; }); + sandbox.stub(res, 'set', function (value) { + // Test that the headers are correct + value['Cache-Control'].should.eql('no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'); + return res; + }); + err.code = 500; errors.error500(err, req, res, null); }); diff --git a/package.json b/package.json index 7f5976812e6..003eec79c7d 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "test": "./node_modules/.bin/grunt validate --verbose" }, "engines": { - "node": "~0.10.0" + "node": "~0.10.0 || ~0.12.0", + "iojs": "~1.2.0" }, "engineStrict": true, "dependencies": { @@ -46,7 +47,7 @@ "extract-zip": "1.0.3", "fs-extra": "0.13.0", "glob": "4.3.2", - "html-to-text": "1.0.0", + "html-to-text": "1.2.0", "knex": "0.7.3", "lodash": "2.4.1", "moment": "2.8.3", @@ -62,7 +63,7 @@ "rss": "1.0.0", "semver": "4.1.0", "showdown-ghost": "0.3.4", - "sqlite3": "3.0.4", + "sqlite3": "3.0.5", "unidecode": "0.1.3", "validator": "3.28.0", "xml": "0.0.12" @@ -91,7 +92,7 @@ "grunt-express-server": "~0.4.19", "grunt-jscs": "~1.2.0", "grunt-mocha-cli": "~1.11.0", - "grunt-sass": "~0.17.0", + "grunt-sass": "~0.18.0", "grunt-shell": "~1.1.1", "grunt-update-submodules": "~0.4.1", "matchdep": "~0.3.0",