From ff73f1af92a8a114d6ec92c625c72508015e501b Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 12 Oct 2015 17:54:15 +0100 Subject: [PATCH] deps: grunt-jscs@2.1.0 no issue - update grunt-jscs dependency - fix deprecated `validateJSDoc` configuration - fix numerous linting errors, including: - use of future-reserved `public` and `private` variable names - use of `[]` instead of dot-notation (especially `express['static']` and `cacheRules['x']`) - extra spaces in `const { run } = Ember` style constructs One issue that did become apparent is that there are conflicting rules that prevent the use of object function shorthand such that both of these: ``` { myFunc() {} } { myFunc () {} } ``` are called out due to either the missing or the extra space before the `(` --- .jscsrc | 2 +- core/client/app/components/gh-selectize.js | 4 +- .../acceptance/settings/navigation-test.js | 2 +- .../components/gh-navigation-test.js | 2 +- .../integration/components/gh-navitem-test.js | 2 +- .../components/gh-navitem-url-input-test.js | 2 +- .../controllers/settings/navigation-test.js | 2 +- core/server/api/utils.js | 3 +- core/server/helpers/author.js | 2 +- core/server/index.js | 2 +- core/server/middleware/cache-control.js | 2 +- core/server/middleware/index.js | 6 +- core/server/middleware/private-blogging.js | 8 +- core/server/middleware/static-theme.js | 2 +- core/server/storage/local-file-store.js | 2 +- core/test/functional/base.js | 4 +- core/test/functional/routes/admin_spec.js | 6 +- .../routes/api/authentication_spec.js | 6 +- core/test/functional/routes/api/db_spec.js | 2 +- core/test/functional/routes/api/error_spec.js | 2 +- .../routes/api/notifications_spec.js | 4 +- core/test/functional/routes/api/posts_spec.js | 96 +++++++++---------- .../functional/routes/api/settings_spec.js | 16 ++-- core/test/functional/routes/api/slugs_spec.js | 10 +- core/test/functional/routes/api/tags_spec.js | 2 +- core/test/functional/routes/api/users_spec.js | 30 +++--- core/test/functional/routes/frontend_spec.js | 86 ++++++++--------- core/test/unit/error_handling_spec.js | 6 +- .../unit/middleware/cache-control_spec.js | 12 +-- core/test/unit/permissions_spec.js | 16 ++-- package.json | 2 +- 31 files changed, 171 insertions(+), 172 deletions(-) diff --git a/.jscsrc b/.jscsrc index bb1e481d10..6df9747b94 100644 --- a/.jscsrc +++ b/.jscsrc @@ -66,7 +66,7 @@ "safeContextKeyword": ["self"], "requireDotNotation": true, "disallowYodaConditions": true, - "validateJSDoc": { + "jsDoc": { "checkParamNames": true, "checkRedundantParams": true, "requireParamTypes": true diff --git a/core/client/app/components/gh-selectize.js b/core/client/app/components/gh-selectize.js index a00b9db65e..5286ac33ad 100644 --- a/core/client/app/components/gh-selectize.js +++ b/core/client/app/components/gh-selectize.js @@ -27,7 +27,7 @@ export default EmberSelectizeComponent.extend({ * Event callback that is triggered when user creates a tag * - modified to pass the caret position to the action */ - _create(input, callback) { + _create: function (input, callback) { var caret = this._selectize.caretPos; // Delete user entered text @@ -43,7 +43,7 @@ export default EmberSelectizeComponent.extend({ callback(null); }, - _addSelection(obj) { + _addSelection: function (obj) { var _valuePath = this.get('_valuePath'), val = Ember.get(obj, _valuePath), caret = this._selectize.caretPos; diff --git a/core/client/tests/acceptance/settings/navigation-test.js b/core/client/tests/acceptance/settings/navigation-test.js index 026f2e922a..c751f7145b 100644 --- a/core/client/tests/acceptance/settings/navigation-test.js +++ b/core/client/tests/acceptance/settings/navigation-test.js @@ -13,7 +13,7 @@ import initializeTestHelpers from 'simple-auth-testing/test-helpers'; initializeTestHelpers(); -const { run } = Ember, +const {run} = Ember, // TODO: Pull this into a fixture or similar when required elsewhere requiredSettings = [{ created_at: '2015-09-11T09:44:30.805Z', diff --git a/core/client/tests/integration/components/gh-navigation-test.js b/core/client/tests/integration/components/gh-navigation-test.js index 74451d864c..fc180bef45 100644 --- a/core/client/tests/integration/components/gh-navigation-test.js +++ b/core/client/tests/integration/components/gh-navigation-test.js @@ -5,7 +5,7 @@ import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; import { NavItem } from 'ghost/controllers/settings/navigation'; -const { run } = Ember; +const {run} = Ember; describeComponent( 'gh-navigation', diff --git a/core/client/tests/integration/components/gh-navitem-test.js b/core/client/tests/integration/components/gh-navitem-test.js index 3df3789334..559b2527aa 100644 --- a/core/client/tests/integration/components/gh-navitem-test.js +++ b/core/client/tests/integration/components/gh-navitem-test.js @@ -5,7 +5,7 @@ import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; import { NavItem } from 'ghost/controllers/settings/navigation'; -const { run } = Ember; +const {run} = Ember; describeComponent( 'gh-navitem', diff --git a/core/client/tests/integration/components/gh-navitem-url-input-test.js b/core/client/tests/integration/components/gh-navitem-url-input-test.js index fca474dcfa..a0e0606338 100644 --- a/core/client/tests/integration/components/gh-navitem-url-input-test.js +++ b/core/client/tests/integration/components/gh-navitem-url-input-test.js @@ -7,7 +7,7 @@ import { import hbs from 'htmlbars-inline-precompile'; import Ember from 'ember'; -const { run } = Ember, +const {run} = Ember, // we want baseUrl to match the running domain so relative URLs are // handled as expected (browser auto-sets the domain when using a.href) currentUrl = `${window.location.protocol}//${window.location.host}/`; diff --git a/core/client/tests/unit/controllers/settings/navigation-test.js b/core/client/tests/unit/controllers/settings/navigation-test.js index 88c822c71a..66c4370dd4 100644 --- a/core/client/tests/unit/controllers/settings/navigation-test.js +++ b/core/client/tests/unit/controllers/settings/navigation-test.js @@ -4,7 +4,7 @@ import { describeModule, it } from 'ember-mocha'; import Ember from 'ember'; import { NavItem } from 'ghost/controllers/settings/navigation'; -const { run } = Ember; +const {run} = Ember; var navSettingJSON = `[ {"label":"Home","url":"/"}, diff --git a/core/server/api/utils.js b/core/server/api/utils.js index ab1407d162..1d3ca57df7 100644 --- a/core/server/api/utils.js +++ b/core/server/api/utils.js @@ -38,8 +38,7 @@ utils = { /** * ### Do Validate * Validate the object and options passed to an endpoint - * @argument object - * @argument options + * @argument {...*} [arguments] object or object and options hash */ return function doValidate() { var object, options, permittedOptions; diff --git a/core/server/helpers/author.js b/core/server/helpers/author.js index ce48bf48de..1fbc0020bb 100644 --- a/core/server/helpers/author.js +++ b/core/server/helpers/author.js @@ -22,7 +22,7 @@ author = function (context, options) { } if (options.fn) { - return hbs.handlebars.helpers['with'].call(this, this.author, options); + return hbs.handlebars.helpers.with.call(this, this.author, options); } var autolink = _.isString(options.hash.autolink) && options.hash.autolink === 'false' ? false : true, diff --git a/core/server/index.js b/core/server/index.js index 657b34bfe3..349ca3ffe8 100644 --- a/core/server/index.js +++ b/core/server/index.js @@ -178,7 +178,7 @@ function init(options) { // ##Configuration // return the correct mime type for woff files - express['static'].mime.define({'application/font-woff': ['woff']}); + express.static.mime.define({'application/font-woff': ['woff']}); // enabled gzip compression by default if (config.server.compress !== false) { diff --git a/core/server/middleware/cache-control.js b/core/server/middleware/cache-control.js index 16ebc6e5c8..1eeabe8fb9 100644 --- a/core/server/middleware/cache-control.js +++ b/core/server/middleware/cache-control.js @@ -24,7 +24,7 @@ cacheControl = function cacheControl(options) { return function cacheControlHeaders(req, res, next) { if (output) { if (res.isPrivateBlog) { - res.set({'Cache-Control': profiles['private']}); + res.set({'Cache-Control': profiles.private}); } else { res.set({'Cache-Control': output}); } diff --git a/core/server/middleware/index.js b/core/server/middleware/index.js index 20d32782d5..a076d91407 100644 --- a/core/server/middleware/index.js +++ b/core/server/middleware/index.js @@ -78,9 +78,9 @@ setupMiddleware = function setupMiddleware(blogApp, adminApp) { blogApp.use(serveSharedFile('favicon.ico', 'image/x-icon', utils.ONE_DAY_S)); // Static assets - blogApp.use('/shared', express['static'](path.join(corePath, '/shared'), {maxAge: utils.ONE_HOUR_MS})); + blogApp.use('/shared', express.static(path.join(corePath, '/shared'), {maxAge: utils.ONE_HOUR_MS})); blogApp.use('/content/images', storage.getStorage().serve()); - blogApp.use('/public', express['static'](path.join(corePath, '/built/public'), {maxAge: utils.ONE_YEAR_MS})); + blogApp.use('/public', express.static(path.join(corePath, '/built/public'), {maxAge: utils.ONE_YEAR_MS})); // First determine whether we're serving admin or theme content blogApp.use(decideIsAdmin); @@ -88,7 +88,7 @@ setupMiddleware = function setupMiddleware(blogApp, adminApp) { blogApp.use(themeHandler.configHbsForContext); // Admin only config - blogApp.use('/ghost', express['static'](config.paths.clientAssets, {maxAge: utils.ONE_YEAR_MS})); + blogApp.use('/ghost', express.static(config.paths.clientAssets, {maxAge: utils.ONE_YEAR_MS})); // Force SSL // NOTE: Importantly this is _after_ the check above for admin-theme static resources, diff --git a/core/server/middleware/private-blogging.js b/core/server/middleware/private-blogging.js index ec83f0d233..63938b9b55 100644 --- a/core/server/middleware/private-blogging.js +++ b/core/server/middleware/private-blogging.js @@ -8,7 +8,7 @@ var _ = require('lodash'), errors = require('../errors'), session = require('cookie-session'), utils = require('../utils'), - private; + privateBlogging; function verifySessionHash(salt, hash) { if (!salt || !hash) { @@ -24,7 +24,7 @@ function verifySessionHash(salt, hash) { }); } -private = { +privateBlogging = { checkIsPrivate: function checkIsPrivate(req, res, next) { return api.settings.read({context: {internal: true}, key: 'isPrivate'}).then(function then(response) { var pass = response.settings[0]; @@ -64,7 +64,7 @@ private = { res.end(buf); }); } else { - return private.authenticatePrivateSession(req, res, next); + return privateBlogging.authenticatePrivateSession(req, res, next); } }, @@ -133,4 +133,4 @@ private = { } }; -module.exports = private; +module.exports = privateBlogging; diff --git a/core/server/middleware/static-theme.js b/core/server/middleware/static-theme.js index 06dc745e22..3b6654f8c7 100644 --- a/core/server/middleware/static-theme.js +++ b/core/server/middleware/static-theme.js @@ -11,7 +11,7 @@ function isBlackListedFileType(file) { } function forwardToExpressStatic(req, res, next) { - express['static']( + express.static( path.join(config.paths.themePath, req.app.get('activeTheme')), {maxAge: utils.ONE_YEAR_MS} )(req, res, next); diff --git a/core/server/storage/local-file-store.js b/core/server/storage/local-file-store.js index 4facc5b050..d1b4d39511 100644 --- a/core/server/storage/local-file-store.js +++ b/core/server/storage/local-file-store.js @@ -52,7 +52,7 @@ LocalFileStore.prototype.exists = function (filename) { // middleware for serving the files LocalFileStore.prototype.serve = function () { // For some reason send divides the max age number by 1000 - return express['static'](config.paths.imagesPath, {maxAge: utils.ONE_YEAR_MS}); + return express.static(config.paths.imagesPath, {maxAge: utils.ONE_YEAR_MS}); }; module.exports = LocalFileStore; diff --git a/core/test/functional/base.js b/core/test/functional/base.js index 2332915eed..9f1956bb6f 100644 --- a/core/test/functional/base.js +++ b/core/test/functional/base.js @@ -291,7 +291,7 @@ casper.on('error', function (msg, trace) { if (trace && trace[0]) { casper.echoConcise('file: ' + trace[0].file, 'WARNING'); casper.echoConcise('line: ' + trace[0].line, 'WARNING'); - casper.echoConcise('function: ' + trace[0]['function'], 'WARNING'); + casper.echoConcise('function: ' + trace[0].function, 'WARNING'); } jsErrors.push(msg); }); @@ -302,7 +302,7 @@ casper.on('page.error', function (msg, trace) { if (trace && trace[0]) { casper.echoConcise('file: ' + trace[0].file, 'WARNING'); casper.echoConcise('line: ' + trace[0].line, 'WARNING'); - casper.echoConcise('function: ' + trace[0]['function'], 'WARNING'); + casper.echoConcise('function: ' + trace[0].function, 'WARNING'); } pageErrors.push(msg); }); diff --git a/core/test/functional/routes/admin_spec.js b/core/test/functional/routes/admin_spec.js index 09d289fd12..4ceb92fe41 100644 --- a/core/test/functional/routes/admin_spec.js +++ b/core/test/functional/routes/admin_spec.js @@ -188,7 +188,7 @@ describe('Admin Routing', function () { it('should redirect from /ghost/ to /ghost/setup/ when no user/not installed yet', function (done) { request.get('/ghost/') .expect('Location', /ghost\/setup/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(302) .end(doEnd(done)); }); @@ -196,7 +196,7 @@ describe('Admin Routing', function () { it('should redirect from /ghost/signin/ to /ghost/setup/ when no user', function (done) { request.get('/ghost/signin/') .expect('Location', /ghost\/setup/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(302) .end(doEnd(done)); }); @@ -204,7 +204,7 @@ describe('Admin Routing', function () { it('should respond with html for /ghost/setup/', function (done) { request.get('/ghost/setup/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(doEnd(done)); }); diff --git a/core/test/functional/routes/api/authentication_spec.js b/core/test/functional/routes/api/authentication_spec.js index 185794ec54..bc21d9f8d8 100644 --- a/core/test/functional/routes/api/authentication_spec.js +++ b/core/test/functional/routes/api/authentication_spec.js @@ -54,7 +54,7 @@ describe('Authentication API', function () { request.post(testUtils.API.getApiQuery('authentication/token')) .send({grant_type: 'password', username: 'invalid@email.com', password: user.password, client_id: 'ghost-admin', client_secret: 'not_available'}) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -71,7 +71,7 @@ describe('Authentication API', function () { request.post(testUtils.API.getApiQuery('authentication/token')) .send({grant_type: 'password', username: user.email, password: 'invalid', client_id: 'ghost-admin', client_secret: 'not_available'}) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(401) .end(function (err, res) { if (err) { @@ -118,7 +118,7 @@ describe('Authentication API', function () { request.post(testUtils.API.getApiQuery('authentication/token')) .send({grant_type: 'refresh_token', refresh_token: 'invalid', client_id: 'ghost-admin', client_secret: 'not_available'}) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(403) .end(function (err, res) { if (err) { diff --git a/core/test/functional/routes/api/db_spec.js b/core/test/functional/routes/api/db_spec.js index 5928b8a797..bdac308cbd 100644 --- a/core/test/functional/routes/api/db_spec.js +++ b/core/test/functional/routes/api/db_spec.js @@ -32,7 +32,7 @@ describe('DB API', function () { request.get(testUtils.API.getApiQuery('db/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .expect('Content-Disposition', /Attachment; filename="[A-Za-z0-9._-]+\.json"/) .end(function (err, res) { diff --git a/core/test/functional/routes/api/error_spec.js b/core/test/functional/routes/api/error_spec.js index 321b50dc36..72e1b800ab 100644 --- a/core/test/functional/routes/api/error_spec.js +++ b/core/test/functional/routes/api/error_spec.js @@ -30,7 +30,7 @@ describe('Unauthorized', function () { describe('Unauthorized API', function () { it('can\'t retrieve posts', function (done) { request.get(testUtils.API.getApiQuery('posts/')) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(401) .end(function firstRequest(err, res) { if (err) { diff --git a/core/test/functional/routes/api/notifications_spec.js b/core/test/functional/routes/api/notifications_spec.js index e7464ca393..6442123ba5 100644 --- a/core/test/functional/routes/api/notifications_spec.js +++ b/core/test/functional/routes/api/notifications_spec.js @@ -40,7 +40,7 @@ describe('Notifications API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send({notifications: [newNotification]}) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(201) .end(function (err, res) { if (err) { @@ -75,7 +75,7 @@ describe('Notifications API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send({notifications: [newNotification]}) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(201) .end(function (err, res) { if (err) { diff --git a/core/test/functional/routes/api/posts_spec.js b/core/test/functional/routes/api/posts_spec.js index 3f2e166f37..aa169eb5da 100644 --- a/core/test/functional/routes/api/posts_spec.js +++ b/core/test/functional/routes/api/posts_spec.js @@ -36,7 +36,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -60,7 +60,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/?staticPages=all')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -84,7 +84,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/?staticPages=all&status=all')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -106,7 +106,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/?staticPages=true')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -128,7 +128,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/?featured=true')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -150,7 +150,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/?status=draft')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -175,7 +175,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -204,7 +204,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/slug/welcome-to-ghost/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -232,7 +232,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/?include=author,tags,created_by')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -258,7 +258,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/3/?include=next,previous')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -284,7 +284,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/7/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -306,7 +306,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/99/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -326,7 +326,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/5/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -346,7 +346,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/8/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -376,7 +376,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(newPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(201) .end(function (err, res) { if (err) { @@ -400,7 +400,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(draftPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -427,7 +427,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(publishedPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -464,7 +464,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/?include=tags')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -481,7 +481,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -510,7 +510,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(newPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(201) .end(function (err, res) { if (err) { @@ -530,7 +530,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(draftPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -555,7 +555,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(newPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(201) .end(function (err, res) { if (err) { @@ -576,7 +576,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(draftPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -594,7 +594,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/?include=tags')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -610,7 +610,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -632,7 +632,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/7/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -648,7 +648,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -670,7 +670,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/7/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -686,7 +686,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(422) .end(function (err, res) { if (err) { @@ -706,7 +706,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { /*jshint unused:false*/ if (err) { @@ -718,7 +718,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + 'invalidtoken') .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(401) .end(function (err, res) { /*jshint unused:false*/ @@ -735,7 +735,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -748,7 +748,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(400) .end(function (err, res) { /*jshint unused:false*/ @@ -765,7 +765,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/?include=tags')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -781,7 +781,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -807,7 +807,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/1/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -822,7 +822,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -846,7 +846,7 @@ describe('Post API', function () { request.del(testUtils.API.getApiQuery('posts/' + deletePostId + '/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -867,7 +867,7 @@ describe('Post API', function () { request.del(testUtils.API.getApiQuery('posts/99/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -892,7 +892,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(newPost) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(201) .end(function (err, res) { if (err) { @@ -909,7 +909,7 @@ describe('Post API', function () { request.del(testUtils.API.getApiQuery('posts/' + draftPost.posts[0].id + '/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -931,7 +931,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -944,7 +944,7 @@ describe('Post API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { /*jshint unused:false*/ if (err) { @@ -959,7 +959,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -971,7 +971,7 @@ describe('Post API', function () { request.put(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .send(jsonResponse) .end(function (err, res) { /*jshint unused:false*/ @@ -989,7 +989,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/2/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -1012,7 +1012,7 @@ describe('Post API', function () { request.get(testUtils.API.getApiQuery('posts/2/?include=tags')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -1027,7 +1027,7 @@ describe('Post API', function () { request.put(testUtils.API.getApiQuery('posts/2/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .send(jsonResponse) .expect(200) .end(function (err, res) { diff --git a/core/test/functional/routes/api/settings_spec.js b/core/test/functional/routes/api/settings_spec.js index c6d020afdc..2eb68e4d23 100644 --- a/core/test/functional/routes/api/settings_spec.js +++ b/core/test/functional/routes/api/settings_spec.js @@ -35,7 +35,7 @@ describe('Settings API', function () { request.get(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -55,7 +55,7 @@ describe('Settings API', function () { request.get(testUtils.API.getApiQuery('settings/title/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -79,7 +79,7 @@ describe('Settings API', function () { request.get(testUtils.API.getApiQuery('settings/testsetting/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -99,7 +99,7 @@ describe('Settings API', function () { request.get(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -120,7 +120,7 @@ describe('Settings API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(settingToChange) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -141,7 +141,7 @@ describe('Settings API', function () { request.get(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -171,7 +171,7 @@ describe('Settings API', function () { request.get(testUtils.API.getApiQuery('settings/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -187,7 +187,7 @@ describe('Settings API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(jsonResponse) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { diff --git a/core/test/functional/routes/api/slugs_spec.js b/core/test/functional/routes/api/slugs_spec.js index 028f56e1eb..83ab2462db 100644 --- a/core/test/functional/routes/api/slugs_spec.js +++ b/core/test/functional/routes/api/slugs_spec.js @@ -34,7 +34,7 @@ describe('Slug API', function () { request.get(testUtils.API.getApiQuery('slugs/post/a post title/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -57,7 +57,7 @@ describe('Slug API', function () { request.get(testUtils.API.getApiQuery('slugs/post/atag/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -80,7 +80,7 @@ describe('Slug API', function () { request.get(testUtils.API.getApiQuery('slugs/user/user name/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -103,7 +103,7 @@ describe('Slug API', function () { request.get(testUtils.API.getApiQuery('slugs/app/cool app/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -126,7 +126,7 @@ describe('Slug API', function () { request.get(testUtils.API.getApiQuery('slugs/unknown/who knows/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(400) .end(function (err, res) { if (err) { diff --git a/core/test/functional/routes/api/tags_spec.js b/core/test/functional/routes/api/tags_spec.js index d733e3585f..d13806add3 100644 --- a/core/test/functional/routes/api/tags_spec.js +++ b/core/test/functional/routes/api/tags_spec.js @@ -34,7 +34,7 @@ describe('Tag API', function () { request.get(testUtils.API.getApiQuery('tags/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { diff --git a/core/test/functional/routes/api/users_spec.js b/core/test/functional/routes/api/users_spec.js index 92f16c0b96..b140043256 100644 --- a/core/test/functional/routes/api/users_spec.js +++ b/core/test/functional/routes/api/users_spec.js @@ -35,7 +35,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -61,7 +61,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -83,7 +83,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/?include=roles')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -107,7 +107,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/me/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -129,7 +129,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/1/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -151,7 +151,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/slug/joe-bloggs/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -173,7 +173,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/email/jbloggs%40example.com/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -195,7 +195,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/me/?include=roles')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -218,7 +218,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/me/?include=roles,roles.permissions')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -243,7 +243,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/slug/joe-bloggs/?include=roles,roles.permissions')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -268,7 +268,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/99/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -288,7 +288,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/slug/blargh/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .end(function (err, res) { if (err) { @@ -309,7 +309,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/me/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); @@ -329,7 +329,7 @@ describe('User API', function () { .set('Authorization', 'Bearer ' + accesstoken) .send(dataToSend) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(200) .end(function (err, res) { if (err) { @@ -351,7 +351,7 @@ describe('User API', function () { request.get(testUtils.API.getApiQuery('users/me/')) .set('Authorization', 'Bearer ' + accesstoken) .expect('Content-Type', /json/) - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .end(function (err, res) { if (err) { return done(err); diff --git a/core/test/functional/routes/frontend_spec.js b/core/test/functional/routes/frontend_spec.js index cd266c0491..bca011c248 100644 --- a/core/test/functional/routes/frontend_spec.js +++ b/core/test/functional/routes/frontend_spec.js @@ -57,7 +57,7 @@ describe('Frontend Routing', function () { describe('Error', function () { it('should 404 for unknown post', function (done) { request.get('/spectacular/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -65,7 +65,7 @@ describe('Frontend Routing', function () { it('should 404 for unknown post with invalid characters', function (done) { request.get('/$pec+acular~/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -73,7 +73,7 @@ describe('Frontend Routing', function () { it('should 404 for unknown frontend route', function (done) { request.get('/spectacular/marvellous/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -81,7 +81,7 @@ describe('Frontend Routing', function () { it('should 404 for unknown tag', function (done) { request.get('/tag/spectacular/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -89,7 +89,7 @@ describe('Frontend Routing', function () { it('should 404 for unknown tag with invalid characters', function (done) { request.get('/tag/~$pectacular~/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -97,7 +97,7 @@ describe('Frontend Routing', function () { it('should 404 for unknown author', function (done) { request.get('/author/spectacular/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -105,7 +105,7 @@ describe('Frontend Routing', function () { it('should 404 for encoded char not 301 from uncapitalise', function (done) { request.get('/|/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -113,7 +113,7 @@ describe('Frontend Routing', function () { it('should 404 for unknown author with invalid characters', function (done) { request.get('/author/ghost!user^/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -124,7 +124,7 @@ describe('Frontend Routing', function () { it('should respond with html', function (done) { request.get('/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(function (err, res) { if (err) { @@ -152,7 +152,7 @@ describe('Frontend Routing', function () { it('should not have as second page', function (done) { request.get('/page/2/') .expect('Location', '/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -178,7 +178,7 @@ describe('Frontend Routing', function () { it('should respond with html for valid url', function (done) { request.get('/welcome-to-ghost/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(function (err, res) { if (err) { @@ -209,7 +209,7 @@ describe('Frontend Routing', function () { var date = moment().format('YYYY/MM/DD'); request.get('/' + date + '/welcome-to-ghost/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -228,14 +228,14 @@ describe('Frontend Routing', function () { it('should redirect to editor', function (done) { request.get('/welcome-to-ghost/edit/') .expect('Location', '/ghost/editor/1/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); it('should 404 for non-edit parameter', function (done) { request.get('/welcome-to-ghost/notedit/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -305,7 +305,7 @@ describe('Frontend Routing', function () { it('should respond with xml', function (done) { request.get('/static-page-test/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -366,7 +366,7 @@ describe('Frontend Routing', function () { // Badly formed regexs can cause breakage if a post slug starts with the 5 letters ghost it('should retrieve a blog post with ghost at the start of the url', function (done) { request.get('/ghostly-kitchen-sink/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -399,7 +399,7 @@ describe('Frontend Routing', function () { it('should respond with html', function (done) { request.get('/page/2/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -407,7 +407,7 @@ describe('Frontend Routing', function () { it('should redirect page 1', function (done) { request.get('/page/1/') .expect('Location', '/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) // TODO: This should probably be a 301? .expect(302) .end(doEnd(done)); @@ -416,7 +416,7 @@ describe('Frontend Routing', function () { it('should redirect to last page if page too high', function (done) { request.get('/page/4/') .expect('Location', '/page/3/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -424,7 +424,7 @@ describe('Frontend Routing', function () { it('should redirect to first page if page too low', function (done) { request.get('/page/0/') .expect('Location', '/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -457,7 +457,7 @@ describe('Frontend Routing', function () { it('should respond with 200 & CC=public', function (done) { request.get('/rss/') .expect('Content-Type', 'text/xml; charset=utf-8') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(function (err, res) { if (err) { @@ -502,7 +502,7 @@ describe('Frontend Routing', function () { it('should respond with xml', function (done) { request.get('/rss/2/') .expect('Content-Type', /xml/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -528,7 +528,7 @@ describe('Frontend Routing', function () { it('should 404 for /author/ route', function (done) { request.get('/author/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -545,7 +545,7 @@ describe('Frontend Routing', function () { it('should respond with html', function (done) { request.get('/author/ghost-owner/page/2/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -553,7 +553,7 @@ describe('Frontend Routing', function () { it('should redirect page 1', function (done) { request.get('/author/ghost-owner/page/1/') .expect('Location', '/author/ghost-owner/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) // TODO: This should probably be a 301? .expect(302) .end(doEnd(done)); @@ -562,7 +562,7 @@ describe('Frontend Routing', function () { it('should redirect to last page if page too high', function (done) { request.get('/author/ghost-owner/page/4/') .expect('Location', '/author/ghost-owner/page/3/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -570,7 +570,7 @@ describe('Frontend Routing', function () { it('should redirect to first page if page too low', function (done) { request.get('/author/ghost-owner/page/0/') .expect('Location', '/author/ghost-owner/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -587,7 +587,7 @@ describe('Frontend Routing', function () { it('should respond with xml', function (done) { request.get('/author/ghost-owner/rss/') .expect('Content-Type', /xml/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -595,7 +595,7 @@ describe('Frontend Routing', function () { it('should redirect page 1', function (done) { request.get('/author/ghost-owner/rss/1/') .expect('Location', '/author/ghost-owner/rss/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) // TODO: This should probably be a 301? .expect(302) .end(doEnd(done)); @@ -604,7 +604,7 @@ describe('Frontend Routing', function () { it('should redirect to last page if page too high', function (done) { request.get('/author/ghost-owner/rss/2/') .expect('Location', '/author/ghost-owner/rss/1/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -612,7 +612,7 @@ describe('Frontend Routing', function () { it('should redirect to first page if page too low', function (done) { request.get('/author/ghost-owner/rss/0/') .expect('Location', '/author/ghost-owner/rss/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -630,14 +630,14 @@ describe('Frontend Routing', function () { it('should redirect to editor', function (done) { request.get('/author/ghost-owner/edit/') .expect('Location', '/ghost/team/ghost-owner/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); it('should 404 for something that isn\'t edit', function (done) { request.get('/author/ghost-owner/notedit/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -663,7 +663,7 @@ describe('Frontend Routing', function () { it('should 404 for /tag/ route', function (done) { request.get('/tag/') - .expect('Cache-Control', testUtils.cacheRules['private']) + .expect('Cache-Control', testUtils.cacheRules.private) .expect(404) .expect(/Page not found/) .end(doEnd(done)); @@ -680,7 +680,7 @@ describe('Frontend Routing', function () { it('should respond with html', function (done) { request.get('/tag/injection/page/2/') .expect('Content-Type', /html/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -688,7 +688,7 @@ describe('Frontend Routing', function () { it('should redirect page 1', function (done) { request.get('/tag/injection/page/1/') .expect('Location', '/tag/injection/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) // TODO: This should probably be a 301? .expect(302) .end(doEnd(done)); @@ -697,7 +697,7 @@ describe('Frontend Routing', function () { it('should redirect to last page if page too high', function (done) { request.get('/tag/injection/page/4/') .expect('Location', '/tag/injection/page/3/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -705,7 +705,7 @@ describe('Frontend Routing', function () { it('should redirect to first page if page too low', function (done) { request.get('/tag/injection/page/0/') .expect('Location', '/tag/injection/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -722,7 +722,7 @@ describe('Frontend Routing', function () { it('should respond with xml', function (done) { request.get('/tag/getting-started/rss/') .expect('Content-Type', /xml/) - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(doEnd(done)); }); @@ -730,7 +730,7 @@ describe('Frontend Routing', function () { it('should redirect page 1', function (done) { request.get('/tag/getting-started/rss/1/') .expect('Location', '/tag/getting-started/rss/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) // TODO: This should probably be a 301? .expect(302) .end(doEnd(done)); @@ -739,7 +739,7 @@ describe('Frontend Routing', function () { it('should redirect to last page if page too high', function (done) { request.get('/tag/getting-started/rss/2/') .expect('Location', '/tag/getting-started/rss/1/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -747,7 +747,7 @@ describe('Frontend Routing', function () { it('should redirect to first page if page too low', function (done) { request.get('/tag/getting-started/rss/0/') .expect('Location', '/tag/getting-started/rss/') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(302) .end(doEnd(done)); }); @@ -978,7 +978,7 @@ describe('Frontend Routing', function () { it('should serve RSS with date permalink', function (done) { request.get('/rss/') .expect('Content-Type', 'text/xml; charset=utf-8') - .expect('Cache-Control', testUtils.cacheRules['public']) + .expect('Cache-Control', testUtils.cacheRules.public) .expect(200) .end(function (err, res) { if (err) { diff --git a/core/test/unit/error_handling_spec.js b/core/test/unit/error_handling_spec.js index dceec34010..2912a1f70c 100644 --- a/core/test/unit/error_handling_spec.js +++ b/core/test/unit/error_handling_spec.js @@ -26,7 +26,7 @@ describe('Error handling', function () { errors.throwError(toThrow); }; - runThrowError.should['throw']('test1'); + runThrowError.should.throw('test1'); }); it('throws error strings', function () { @@ -35,7 +35,7 @@ describe('Error handling', function () { errors.throwError(toThrow); }; - runThrowError.should['throw']('test2'); + runThrowError.should.throw('test2'); }); it('throws error even if nothing passed', function () { @@ -43,7 +43,7 @@ describe('Error handling', function () { errors.throwError(); }; - runThrowError.should['throw']('An error occurred'); + runThrowError.should.throw('An error occurred'); }); }); diff --git a/core/test/unit/middleware/cache-control_spec.js b/core/test/unit/middleware/cache-control_spec.js index d4ff82f03e..0146f67f1b 100644 --- a/core/test/unit/middleware/cache-control_spec.js +++ b/core/test/unit/middleware/cache-control_spec.js @@ -50,25 +50,25 @@ describe('Middleware: cacheControl', function () { }); it('will not get confused between serving public and private', function (done) { - var public = middleware.cacheControl('public'), - private = middleware.cacheControl('private'); + var publicCC = middleware.cacheControl('public'), + privateCC = middleware.cacheControl('private'); - public(null, res, function () { + publicCC(null, res, function () { res.set.calledOnce.should.be.true; res.set.calledWith({'Cache-Control': 'public, max-age=0'}); - private(null, res, function () { + privateCC(null, res, function () { res.set.calledTwice.should.be.true; res.set.calledWith({ 'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' }); - public(null, res, function () { + publicCC(null, res, function () { res.set.calledThrice.should.be.true; res.set.calledWith({'Cache-Control': 'public, max-age=0'}); - private(null, res, function () { + privateCC(null, res, function () { res.set.calledWith({ 'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' }); diff --git a/core/test/unit/permissions_spec.js b/core/test/unit/permissions_spec.js index 5bfe379bd8..e2fb21405c 100644 --- a/core/test/unit/permissions_spec.js +++ b/core/test/unit/permissions_spec.js @@ -142,16 +142,16 @@ describe('Permissions', function () { }); it('should return unchanged object for post with public context', function (done) { - var public = {context: {}}; + var publicContext = {context: {}}; - permissions.applyPublicRules('posts', 'browse', _.cloneDeep(public)).then(function (result) { - result.should.not.eql(public); + permissions.applyPublicRules('posts', 'browse', _.cloneDeep(publicContext)).then(function (result) { + result.should.not.eql(publicContext); result.should.eql({ context: {}, status: 'published' }); - return permissions.applyPublicRules('posts', 'browse', _.extend({}, _.cloneDeep(public), {status: 'published'})); + return permissions.applyPublicRules('posts', 'browse', _.extend({}, _.cloneDeep(publicContext), {status: 'published'})); }).then(function (result) { result.should.eql({ context: {}, @@ -243,16 +243,16 @@ describe('Permissions', function () { }); it('should return unchanged object for user with public context', function (done) { - var public = {context: {}}; + var publicContext = {context: {}}; - permissions.applyPublicRules('users', 'browse', _.cloneDeep(public)).then(function (result) { - result.should.not.eql(public); + permissions.applyPublicRules('users', 'browse', _.cloneDeep(publicContext)).then(function (result) { + result.should.not.eql(publicContext); result.should.eql({ context: {}, status: 'active' }); - return permissions.applyPublicRules('users', 'browse', _.extend({}, _.cloneDeep(public), {status: 'active'})); + return permissions.applyPublicRules('users', 'browse', _.extend({}, _.cloneDeep(publicContext), {status: 'active'})); }).then(function (result) { result.should.eql({ context: {}, diff --git a/package.json b/package.json index c45187311a..99a0a6b96e 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "grunt-contrib-watch": "0.6.1", "grunt-docker": "0.0.10", "grunt-express-server": "0.5.1", - "grunt-jscs": "1.8.0", + "grunt-jscs": "2.1.0", "grunt-mocha-cli": "1.13.0", "grunt-mocha-istanbul": "2.4.0", "grunt-shell": "1.1.2",