From 4e2474a018b3140f07b148aa76873bcf7b3ec632 Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Mon, 24 Apr 2017 19:41:00 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=20settings=20inconsistency=20(#?= =?UTF-8?q?8381)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - replace camelCase settings keys with underscore_case for consistency - discussed here https://github.com/TryGhost/Ghost-Admin/pull/661#discussion_r112939982 --- core/server/api/authentication.js | 4 +-- core/server/api/notifications.js | 6 ++--- core/server/api/settings.js | 4 +-- core/server/api/themes.js | 8 +++--- core/server/apps/index.js | 6 ++--- .../apps/private-blogging/lib/middleware.js | 2 +- .../private-blogging/tests/middleware_spec.js | 8 +++--- core/server/data/import/utils.js | 4 +-- core/server/data/meta/index.js | 2 +- core/server/data/schema/default-settings.json | 22 ++++++++-------- core/server/i18n.js | 2 +- core/server/models/base/listeners.js | 2 +- core/server/models/settings.js | 2 +- core/server/settings/cache.js | 4 +-- core/server/themes/index.js | 2 +- core/server/themes/middleware.js | 4 +-- core/server/themes/to-json.js | 4 +-- core/server/translations/en.json | 6 ++--- core/server/update-check.js | 22 ++++++++-------- core/server/utils/url.js | 2 +- .../routes/api/authentication_spec.js | 2 +- .../integration/api/api_notifications_spec.js | 4 +-- .../test/integration/api/api_settings_spec.js | 26 +++++++++---------- core/test/integration/import_spec.js | 8 +++--- .../integration/model/base/listeners_spec.js | 16 ++++++------ .../unit/controllers/frontend/index_spec.js | 2 +- .../controllers/frontend/templates_spec.js | 6 ++--- .../test/unit/middleware/uncapitalise_spec.js | 4 +-- .../unit/server_helpers/body_class_spec.js | 2 +- core/test/unit/themes/middleware_spec.js | 4 +-- core/test/unit/utils/url_spec.js | 12 ++++----- 31 files changed, 101 insertions(+), 101 deletions(-) diff --git a/core/server/api/authentication.js b/core/server/api/authentication.js index 0e594fa427..546f1ff451 100644 --- a/core/server/api/authentication.js +++ b/core/server/api/authentication.js @@ -158,7 +158,7 @@ authentication = { var options = {context: {internal: true}}, dbHash, token; - return settings.read(_.merge({key: 'dbHash'}, options)) + return settings.read(_.merge({key: 'db_hash'}, options)) .then(function fetchedSettings(response) { dbHash = response.settings[0].value; @@ -286,7 +286,7 @@ authentication = { oldPassword = data.oldPassword, newPassword = data.newPassword; - return settings.read(_.merge({key: 'dbHash'}, options)) + return settings.read(_.merge({key: 'db_hash'}, options)) .then(function fetchedSettings(response) { dbHash = response.settings[0].value; diff --git a/core/server/api/notifications.js b/core/server/api/notifications.js index c39133cc4b..f642fa5735 100644 --- a/core/server/api/notifications.js +++ b/core/server/api/notifications.js @@ -129,16 +129,16 @@ notifications = { var tasks; /** - * Adds the id of notification to "seenNotifications" array. + * Adds the id of notification to "seen_notifications" array. * @param {Object} notification * @return {*|Promise} */ function markAsSeen(notification) { var context = {internal: true}; - return settings.read({key: 'seenNotifications', context: context}).then(function then(response) { + return settings.read({key: 'seen_notifications', context: context}).then(function then(response) { var seenNotifications = JSON.parse(response.settings[0].value); seenNotifications = _.uniqBy(seenNotifications.concat([notification.id])); - return settings.edit({settings: [{key: 'seenNotifications', value: seenNotifications}]}, {context: context}); + return settings.edit({settings: [{key: 'seen_notifications', value: seenNotifications}]}, {context: context}); }); } diff --git a/core/server/api/settings.js b/core/server/api/settings.js index a30883a726..72de574f2e 100644 --- a/core/server/api/settings.js +++ b/core/server/api/settings.js @@ -43,7 +43,7 @@ settingsFilter = function (settings, filter) { * * Takes a keyed JSON object * E.g. - * dbHash: { + * db_hash: { * id: '123abc', * key: 'dbash', * value: 'xxxx', @@ -103,7 +103,7 @@ canEditAllSettings = function (settingsInfo, options) { )); } - if (setting.key === 'activeTheme') { + if (setting.key === 'active_theme') { return Promise.reject( new errors.BadRequestError({ message: i18n.t('errors.api.settings.activeThemeSetViaAPI.error'), diff --git a/core/server/api/themes.js b/core/server/api/themes.js index 979b7ddce6..6524c74fe9 100644 --- a/core/server/api/themes.js +++ b/core/server/api/themes.js @@ -34,7 +34,7 @@ themes = { activate: function activate(options) { var themeName = options.name, newSettings = [{ - key: 'activeTheme', + key: 'active_theme', value: themeName }], loadedTheme, @@ -50,7 +50,7 @@ themes = { if (!loadedTheme) { return Promise.reject(new errors.ValidationError({ message: i18n.t('notices.data.validation.index.themeCannotBeActivated', {themeName: themeName}), - context: 'activeTheme' + context: 'active_theme' })); } @@ -127,7 +127,7 @@ themes = { .then(function activateAndReturn(loadedTheme) { // If this is the active theme, we are overriding // This is a special case of activation - if (zip.shortName === settingsCache.get('activeTheme')) { + if (zip.shortName === settingsCache.get('active_theme')) { // Activate! (sort of) debug('Activating theme (method C, on API "override")', zip.shortName); themeUtils.activate(loadedTheme, checkedTheme); @@ -193,7 +193,7 @@ themes = { throw new errors.ValidationError({message: i18n.t('errors.api.themes.destroyCasper')}); } - if (themeName === settingsCache.get('activeTheme')) { + if (themeName === settingsCache.get('active_theme')) { throw new errors.ValidationError({message: i18n.t('errors.api.themes.destroyActive')}); } diff --git a/core/server/apps/index.js b/core/server/apps/index.js index c0c5f2e3da..c0113bf012 100644 --- a/core/server/apps/index.js +++ b/core/server/apps/index.js @@ -11,7 +11,7 @@ var _ = require('lodash'), availableApps = {}; function getInstalledApps() { - return api.settings.read({context: {internal: true}, key: 'installedApps'}).then(function (response) { + return api.settings.read({context: {internal: true}, key: 'installed_apps'}).then(function (response) { var installed = response.settings[0]; installed.value = installed.value || '[]'; @@ -30,7 +30,7 @@ function saveInstalledApps(installedApps) { return getInstalledApps().then(function (currentInstalledApps) { var updatedAppsInstalled = _.difference(_.uniq(installedApps.concat(currentInstalledApps)), config.get('internalApps')); - return api.settings.edit({settings: [{key: 'installedApps', value: updatedAppsInstalled}]}, {context: {internal: true}}); + return api.settings.edit({settings: [{key: 'installed_apps', value: updatedAppsInstalled}]}, {context: {internal: true}}); }); } @@ -40,7 +40,7 @@ module.exports = { try { // We have to parse the value because it's a string - api.settings.read({context: {internal: true}, key: 'activeApps'}).then(function (response) { + api.settings.read({context: {internal: true}, key: 'active_apps'}).then(function (response) { var aApps = response.settings[0]; appsToLoad = JSON.parse(aApps.value) || []; diff --git a/core/server/apps/private-blogging/lib/middleware.js b/core/server/apps/private-blogging/lib/middleware.js index 49c16bbb98..7d8fc11b8d 100644 --- a/core/server/apps/private-blogging/lib/middleware.js +++ b/core/server/apps/private-blogging/lib/middleware.js @@ -28,7 +28,7 @@ function verifySessionHash(salt, hash) { privateBlogging = { checkIsPrivate: function checkIsPrivate(req, res, next) { - return api.settings.read({context: {internal: true}, key: 'isPrivate'}).then(function then(response) { + return api.settings.read({context: {internal: true}, key: 'is_private'}).then(function then(response) { var pass = response.settings[0]; if (_.isEmpty(pass.value) || pass.value === 'false') { diff --git a/core/server/apps/private-blogging/tests/middleware_spec.js b/core/server/apps/private-blogging/tests/middleware_spec.js index deba8b3c7e..2c75843ac5 100644 --- a/core/server/apps/private-blogging/tests/middleware_spec.js +++ b/core/server/apps/private-blogging/tests/middleware_spec.js @@ -37,9 +37,9 @@ describe('Private Blogging', function () { }); it('checkIsPrivate should call next if not private', function (done) { - apiSettingsStub.withArgs(sinon.match.has('key', 'isPrivate')).returns(Promise.resolve({ + apiSettingsStub.withArgs(sinon.match.has('key', 'is_private')).returns(Promise.resolve({ settings: [{ - key: 'isPrivate', + key: 'is_private', value: 'false' }] })); @@ -53,9 +53,9 @@ describe('Private Blogging', function () { }); it('checkIsPrivate should load session if private', function (done) { - apiSettingsStub.withArgs(sinon.match.has('key', 'isPrivate')).returns(Promise.resolve({ + apiSettingsStub.withArgs(sinon.match.has('key', 'is_private')).returns(Promise.resolve({ settings: [{ - key: 'isPrivate', + key: 'is_private', value: 'true' }] })); diff --git a/core/server/data/import/utils.js b/core/server/data/import/utils.js index 7b9fa49134..19bb17688c 100644 --- a/core/server/data/import/utils.js +++ b/core/server/data/import/utils.js @@ -12,8 +12,8 @@ var Promise = require('bluebird'), stripProperties; updatedSettingKeys = { - activePlugins: 'activeApps', - installedPlugins: 'installedApps' + activePlugins: 'active_apps', + installedPlugins: 'installed_apps' }; areEmpty = function (object) { diff --git a/core/server/data/meta/index.js b/core/server/data/meta/index.js index ba11b783f0..e3c5dd1d9e 100644 --- a/core/server/data/meta/index.js +++ b/core/server/data/meta/index.js @@ -54,7 +54,7 @@ function getMetaData(data, root) { url: utils.url.urlFor('home', true), facebook: settingsCache.get('facebook'), twitter: settingsCache.get('twitter'), - timezone: settingsCache.get('activeTimezone'), + timezone: settingsCache.get('active_timezone'), navigation: settingsCache.get('navigation'), icon: settingsCache.get('icon'), cover_image: settingsCache.get('cover_image'), diff --git a/core/server/data/schema/default-settings.json b/core/server/data/schema/default-settings.json index d902f3db6b..9423996048 100644 --- a/core/server/data/schema/default-settings.json +++ b/core/server/data/schema/default-settings.json @@ -1,15 +1,15 @@ { "core": { - "dbHash": { + "db_hash": { "defaultValue": null }, - "nextUpdateCheck": { + "next_update_check": { "defaultValue": null }, - "displayUpdateNotification": { + "display_update_notification": { "defaultValue": null }, - "seenNotifications": { + "seen_notifications": { "defaultValue": "[]" } }, @@ -29,20 +29,20 @@ "icon": { "defaultValue": "" }, - "defaultLang": { + "default_lang": { "defaultValue": "en_US", "validations": { "isEmpty": false } }, - "activeTimezone": { + "active_timezone": { "defaultValue": "Etc/UTC", "validations": { "isTimezone": true, "isEmpty": false } }, - "forceI18n": { + "force_i18n": { "defaultValue": "true", "validations": { "isEmpty": false, @@ -83,20 +83,20 @@ } }, "theme": { - "activeTheme": { + "active_theme": { "defaultValue": "casper" } }, "app": { - "activeApps": { + "active_apps": { "defaultValue": "[]" }, - "installedApps": { + "installed_apps": { "defaultValue": "[]" } }, "private": { - "isPrivate": { + "is_private": { "defaultValue": "false" }, "password": { diff --git a/core/server/i18n.js b/core/server/i18n.js index 13268ce4e5..8017392843 100644 --- a/core/server/i18n.js +++ b/core/server/i18n.js @@ -6,7 +6,7 @@ var supportedLocales = ['en'], chalk = require('chalk'), MessageFormat = require('intl-messageformat'), - // TODO: fetch this dynamically based on overall blog settings (`key = "defaultLang"` in the `settings` table + // TODO: fetch this dynamically based on overall blog settings (`key = "default_lang"`) in the `settings` table currentLocale = 'en', blos, I18n; diff --git a/core/server/models/base/listeners.js b/core/server/models/base/listeners.js index a86c613579..c32f58100f 100644 --- a/core/server/models/base/listeners.js +++ b/core/server/models/base/listeners.js @@ -41,7 +41,7 @@ events.on('user.deactivated', function (userModel) { * - reschedule all scheduled posts * - draft scheduled posts, when the published_at would be in the past */ -events.on('settings.activeTimezone.edited', function (settingModel) { +events.on('settings.active_timezone.edited', function (settingModel) { var newTimezone = settingModel.attributes.value, previousTimezone = settingModel._updatedAttributes.value, timezoneOffsetDiff = moment.tz(previousTimezone).utcOffset() - moment.tz(newTimezone).utcOffset(), diff --git a/core/server/models/settings.js b/core/server/models/settings.js index 0177973b25..2cecf45f6e 100644 --- a/core/server/models/settings.js +++ b/core/server/models/settings.js @@ -19,7 +19,7 @@ function parseDefaultSettings() { var defaultSettingsInCategories = require('../data/schema/').defaultSettings, defaultSettingsFlattened = {}, dynamicDefault = { - dbHash: uuid.v4() + db_hash: uuid.v4() }; _.each(defaultSettingsInCategories, function each(settings, categoryName) { diff --git a/core/server/settings/cache.js b/core/server/settings/cache.js index fe30a0f29f..10bdaf3fc3 100644 --- a/core/server/settings/cache.js +++ b/core/server/settings/cache.js @@ -20,12 +20,12 @@ var debug = require('debug')('ghost:settings:cache'), * * { * type: core - * key: dbHash + * key: db_hash * value: ... * } * * But the settings cache does not allow requesting a value by type, only by key. - * e.g. settingsCache.get('dbHash') + * e.g. settingsCache.get('db_hash') */ module.exports = { /** diff --git a/core/server/themes/index.js b/core/server/themes/index.js index 19d3851dc1..03ae15a35b 100644 --- a/core/server/themes/index.js +++ b/core/server/themes/index.js @@ -17,7 +17,7 @@ module.exports = { // Init themes module // TODO: move this once we're clear what needs to happen here init: function initThemes() { - var activeThemeName = settingsCache.get('activeTheme'), + var activeThemeName = settingsCache.get('active_theme'), self = this; debug('init themes', activeThemeName); diff --git a/core/server/themes/middleware.js b/core/server/themes/middleware.js index 9a97b36653..4a8a44c640 100644 --- a/core/server/themes/middleware.js +++ b/core/server/themes/middleware.js @@ -18,7 +18,7 @@ themeMiddleware.ensureActiveTheme = function ensureActiveTheme(req, res, next) { return next(new errors.InternalServerError({ // We use the settingsCache here, because the setting will be set, // even if the theme itself is not usable because it is invalid or missing. - message: i18n.t('errors.middleware.themehandler.missingTheme', {theme: settingsCache.get('activeTheme')}) + message: i18n.t('errors.middleware.themehandler.missingTheme', {theme: settingsCache.get('active_theme')}) })); } @@ -40,7 +40,7 @@ themeMiddleware.updateTemplateData = function updateTemplateData(req, res, next) description: settingsCache.get('description'), facebook: settingsCache.get('facebook'), twitter: settingsCache.get('twitter'), - timezone: settingsCache.get('activeTimezone'), + timezone: settingsCache.get('active_timezone'), navigation: settingsCache.get('navigation'), permalinks: settingsCache.get('permalinks'), icon: settingsCache.get('icon'), diff --git a/core/server/themes/to-json.js b/core/server/themes/to-json.js index 12581045a4..d965912987 100644 --- a/core/server/themes/to-json.js +++ b/core/server/themes/to-json.js @@ -16,13 +16,13 @@ module.exports = function toJSON(name, checkedTheme) { if (!name) { toFilter = themeList.getAll(); // Default to returning the full list - themeResult = packages.filterPackages(toFilter, settingsCache.get('activeTheme')); + themeResult = packages.filterPackages(toFilter, settingsCache.get('active_theme')); } else { // If we pass in a gscan result, convert this instead toFilter = {}; toFilter[name] = themeList.get(name); - themeResult = packages.filterPackages(toFilter, settingsCache.get('activeTheme')); + themeResult = packages.filterPackages(toFilter, settingsCache.get('active_theme')); if (checkedTheme && checkedTheme.results.warning.length > 0) { themeResult[0].warnings = _.cloneDeep(checkedTheme.results.warning); diff --git a/core/server/translations/en.json b/core/server/translations/en.json index 5e0d0203fe..a884bc6642 100644 --- a/core/server/translations/en.json +++ b/core/server/translations/en.json @@ -34,9 +34,9 @@ "errors": { "apps": { "failedToParseActiveAppsSettings": { - "error": "Failed to parse activeApps setting value: {message}", + "error": "Failed to parse active_apps setting value: {message}", "context": "Your apps will not be loaded.", - "help": "Check your settings table for typos in the activeApps value. It should look like: [\"app-1\", \"app2\"] (double quotes required)." + "help": "Check your settings table for typos in the active_apps value. It should look like: [\"app-1\", \"app2\"] (double quotes required)." }, "appWillNotBeLoaded": { "error": "The app will not be loaded", @@ -335,7 +335,7 @@ "problemFindingSetting": "Problem finding setting: {key}", "accessCoreSettingFromExtReq": "Attempted to access core setting from external request", "activeThemeSetViaAPI": { - "error": "Attempted to change activeTheme via settings API", + "error": "Attempted to change active_theme via settings API", "help": "Please activate theme via the themes API endpoints instead" }, "invalidJsonInLabs": "Error: Invalid JSON in settings.labs", diff --git a/core/server/update-check.js b/core/server/update-check.js index bbd0f383fe..0e09af5339 100644 --- a/core/server/update-check.js +++ b/core/server/update-check.js @@ -7,7 +7,7 @@ // // The data collected is as follows: // -// - blog id - a hash of the blog hostname, pathname and dbHash. No identifiable info is stored. +// - blog id - a hash of the blog hostname, pathname and db_hash. No identifiable info is stored. // - ghost version // - node version // - npm version @@ -42,7 +42,7 @@ function updateCheckError(err) { err = errors.utils.deserialize(err); api.settings.edit( - {settings: [{key: 'nextUpdateCheck', value: Math.round(Date.now() / 1000 + 24 * 3600)}]}, + {settings: [{key: 'next_update_check', value: Math.round(Date.now() / 1000 + 24 * 3600)}]}, internal ); @@ -70,7 +70,7 @@ function createCustomNotification(message) { message: message.content }, getAllNotifications = api.notifications.browse({context: {internal: true}}), - getSeenNotifications = api.settings.read(_.extend({key: 'seenNotifications'}, internal)); + getSeenNotifications = api.settings.read(_.extend({key: 'seen_notifications'}, internal)); return Promise.join(getAllNotifications, getSeenNotifications, function joined(all, seen) { var isSeen = _.includes(JSON.parse(seen.settings[0].value || []), notification.id), @@ -96,9 +96,9 @@ function updateCheckData() { mailConfig.transport); return Promise.props({ - hash: api.settings.read(_.extend({key: 'dbHash'}, internal)).reflect(), - theme: api.settings.read(_.extend({key: 'activeTheme'}, internal)).reflect(), - apps: api.settings.read(_.extend({key: 'activeApps'}, internal)) + hash: api.settings.read(_.extend({key: 'db_hash'}, internal)).reflect(), + theme: api.settings.read(_.extend({key: 'active_theme'}, internal)).reflect(), + apps: api.settings.read(_.extend({key: 'active_apps'}, internal)) .then(function (response) { var apps = response.settings[0]; @@ -204,14 +204,14 @@ function updateCheckRequest() { */ function updateCheckResponse(response) { return Promise.all([ - api.settings.edit({settings: [{key: 'nextUpdateCheck', value: response.next_check}]}, internal), - api.settings.edit({settings: [{key: 'displayUpdateNotification', value: response.version}]}, internal) + api.settings.edit({settings: [{key: 'next_update_check', value: response.next_check}]}, internal), + api.settings.edit({settings: [{key: 'display_update_notification', value: response.version}]}, internal) ]).then(function () { var messages = response.messages || []; /** * by default the update check service returns messages: [] - * but the latest release version get's stored anyway, because we adding the `displayUpdateNotification` ^ + * but the latest release version get's stored anyway, because we adding the `display_update_notification` ^ */ return Promise.map(messages, createCustomNotification); }); @@ -221,7 +221,7 @@ function updateCheck() { if (config.isPrivacyDisabled('useUpdateCheck')) { return Promise.resolve(); } else { - return api.settings.read(_.extend({key: 'nextUpdateCheck'}, internal)).then(function then(result) { + return api.settings.read(_.extend({key: 'next_update_check'}, internal)).then(function then(result) { var nextUpdateCheck = result.settings[0]; if (nextUpdateCheck && nextUpdateCheck.value && nextUpdateCheck.value > moment().unix()) { @@ -238,7 +238,7 @@ function updateCheck() { } function showUpdateNotification() { - return api.settings.read(_.extend({key: 'displayUpdateNotification'}, internal)).then(function then(response) { + return api.settings.read(_.extend({key: 'display_update_notification'}, internal)).then(function then(response) { var display = response.settings[0]; if (display && display.value && currentVersion && semver.gt(display.value, currentVersion)) { diff --git a/core/server/utils/url.js b/core/server/utils/url.js index a65e6ab984..550d824c8d 100644 --- a/core/server/utils/url.js +++ b/core/server/utils/url.js @@ -174,7 +174,7 @@ function createUrl(urlPath, absolute, secure) { function urlPathForPost(post) { var output = '', permalinks = settingsCache.get('permalinks'), - publishedAtMoment = moment.tz(post.published_at || Date.now(), settingsCache.get('activeTimezone')), + publishedAtMoment = moment.tz(post.published_at || Date.now(), settingsCache.get('active_timezone')), tags = { year: function () { return publishedAtMoment.format('YYYY'); }, month: function () { return publishedAtMoment.format('MM'); }, diff --git a/core/test/functional/routes/api/authentication_spec.js b/core/test/functional/routes/api/authentication_spec.js index 9d9b213529..9c7da89f1f 100644 --- a/core/test/functional/routes/api/authentication_spec.js +++ b/core/test/functional/routes/api/authentication_spec.js @@ -216,7 +216,7 @@ describe('Authentication API', function () { it('reset password', function (done) { models.Settings - .findOne({key: 'dbHash'}) + .findOne({key: 'db_hash'}) .then(function (response) { var token = utils.tokens.resetToken.generateHash({ expires: Date.now() + (1000 * 60), diff --git a/core/test/integration/api/api_notifications_spec.js b/core/test/integration/api/api_notifications_spec.js index 3a02346f2b..07bfb4fa2e 100644 --- a/core/test/integration/api/api_notifications_spec.js +++ b/core/test/integration/api/api_notifications_spec.js @@ -152,7 +152,7 @@ describe('Notifications API', function () { }); }); - it('can destroy a custom notification and add its uuid to seenNotifications (owner)', function (done) { + it('can destroy a custom notification and add its uuid to seen_notifications (owner)', function (done) { var customNotification = { status: 'alert', type: 'info', @@ -168,7 +168,7 @@ describe('Notifications API', function () { NotificationsAPI.destroy( _.extend({}, testUtils.context.internal, {id: notification.id}) ).then(function () { - return SettingsAPI.read(_.extend({key: 'seenNotifications'}, testUtils.context.internal)); + return SettingsAPI.read(_.extend({key: 'seen_notifications'}, testUtils.context.internal)); }).then(function (response) { should.exist(response); response.settings[0].value.should.containEql(notification.id); diff --git a/core/test/integration/api/api_settings_spec.js b/core/test/integration/api/api_settings_spec.js index b8cebe0b2e..641801f35a 100644 --- a/core/test/integration/api/api_settings_spec.js +++ b/core/test/integration/api/api_settings_spec.js @@ -95,8 +95,8 @@ describe('Settings API', function () { }); it('cannot read core settings if not an internal request', function () { - return callApiWithContext(defaultContext, 'read', {key: 'dbHash'}).then(function () { - throw new Error('Allowed to read dbHash with external request'); + return callApiWithContext(defaultContext, 'read', {key: 'db_hash'}).then(function () { + throw new Error('Allowed to read db_hash with external request'); }).catch(function (error) { should.exist(error); error.errorType.should.eql('NoPermissionError'); @@ -104,7 +104,7 @@ describe('Settings API', function () { }); it('can read core settings if an internal request', function () { - return callApiWithContext(internalContext, 'read', {key: 'dbHash'}).then(function (response) { + return callApiWithContext(internalContext, 'read', {key: 'db_hash'}).then(function (response) { should.exist(response); testUtils.API.checkResponse(response, 'settings'); response.settings.length.should.equal(1); @@ -137,7 +137,7 @@ describe('Settings API', function () { }); it('cannot edit a core setting if not an internal request', function () { - return callApiWithContext(defaultContext, 'edit', {settings: [{key: 'dbHash', value: 'hash'}]}, {}) + return callApiWithContext(defaultContext, 'edit', {settings: [{key: 'db_hash', value: 'hash'}]}, {}) .then(function () { throw new Error('Allowed to edit a core setting as external request'); }).catch(function (err) { @@ -148,7 +148,7 @@ describe('Settings API', function () { }); it('can edit a core setting with an internal request', function () { - return callApiWithContext(internalContext, 'edit', {settings: [{key: 'dbHash', value: 'hash'}]}, {}) + return callApiWithContext(internalContext, 'edit', {settings: [{key: 'db_hash', value: 'hash'}]}, {}) .then(function (response) { should.exist(response); testUtils.API.checkResponse(response, 'settings'); @@ -158,15 +158,15 @@ describe('Settings API', function () { }); it('cannot edit the active theme setting via API even with internal context', function () { - return callApiWithContext(internalContext, 'edit', 'activeTheme', { - settings: [{key: 'activeTheme', value: 'rasper'}] + return callApiWithContext(internalContext, 'edit', 'active_theme', { + settings: [{key: 'active_theme', value: 'rasper'}] }).then(function () { throw new Error('Allowed to change active theme settting'); }).catch(function (err) { should.exist(err); err.errorType.should.eql('BadRequestError'); - err.message.should.eql('Attempted to change activeTheme via settings API'); + err.message.should.eql('Attempted to change active_theme via settings API'); }); }); @@ -180,10 +180,10 @@ describe('Settings API', function () { }); }); - it('set activeTimezone: unknown timezone', function () { - return callApiWithContext(defaultContext, 'edit', {settings: [{key: 'activeTimezone', value: 'MFG'}]}, {}) + it('set active_timezone: unknown timezone', function () { + return callApiWithContext(defaultContext, 'edit', {settings: [{key: 'active_timezone', value: 'MFG'}]}, {}) .then(function () { - throw new Error('We expect that the activeTimezone cannot be stored'); + throw new Error('We expect that the active_timezone cannot be stored'); }).catch(function (errors) { should.exist(errors); errors.length.should.eql(1); @@ -191,7 +191,7 @@ describe('Settings API', function () { }); }); - it('set activeTimezone: known timezone', function () { - return callApiWithContext(defaultContext, 'edit', {settings: [{key: 'activeTimezone', value: 'Etc/UTC'}]}, {}); + it('set active_timezone: known timezone', function () { + return callApiWithContext(defaultContext, 'edit', {settings: [{key: 'active_timezone', value: 'Etc/UTC'}]}, {}); }); }); diff --git a/core/test/integration/import_spec.js b/core/test/integration/import_spec.js index aa4d9bf785..aa1d3f968c 100644 --- a/core/test/integration/import_spec.js +++ b/core/test/integration/import_spec.js @@ -201,8 +201,8 @@ describe('Import', function () { // import no longer requires all data to be dropped, and adds posts posts.length.should.equal(exportData.data.posts.length, 'Wrong number of posts'); - // activeTheme should NOT have been overridden - _.find(settings, {key: 'activeTheme'}).value.should.equal('casper', 'Wrong theme'); + // active_theme should NOT have been overridden + _.find(settings, {key: 'active_theme'}).value.should.equal('casper', 'Wrong theme'); // test tags tags.length.should.equal(exportData.data.tags.length, 'no new tags'); @@ -308,8 +308,8 @@ describe('Import', function () { // import no longer requires all data to be dropped, and adds posts posts.length.should.equal(exportData.data.posts.length, 'Wrong number of posts'); - // activeTheme should NOT have been overridden - _.find(settings, {key: 'activeTheme'}).value.should.equal('casper', 'Wrong theme'); + // active_theme should NOT have been overridden + _.find(settings, {key: 'active_theme'}).value.should.equal('casper', 'Wrong theme'); // test tags tags.length.should.equal(exportData.data.tags.length, 'no new tags'); diff --git a/core/test/integration/model/base/listeners_spec.js b/core/test/integration/model/base/listeners_spec.js index 238cf74d2d..4e1016149d 100644 --- a/core/test/integration/model/base/listeners_spec.js +++ b/core/test/integration/model/base/listeners_spec.js @@ -78,7 +78,7 @@ describe('Models: listeners', function () { }); }); - it('activeTimezone changes from London to Los Angeles', function (done) { + it('active_timezone changes from London to Los Angeles', function (done) { var timeout; /** @@ -102,7 +102,7 @@ describe('Models: listeners', function () { scope.newTimezone = 'America/Los_Angeles'; scope.oldTimezone = 'Europe/London'; - eventsToRemember['settings.activeTimezone.edited']({ + eventsToRemember['settings.active_timezone.edited']({ attributes: {value: scope.newTimezone}, _updatedAttributes: {value: scope.oldTimezone} }); @@ -137,7 +137,7 @@ describe('Models: listeners', function () { })(); }); - it('activeTimezone changes from Baghdad to UTC', function (done) { + it('active_timezone changes from Baghdad to UTC', function (done) { var timeout; /** @@ -159,7 +159,7 @@ describe('Models: listeners', function () { scope.oldTimezone = 'Asia/Baghdad'; scope.newTimezone = 'Etc/UTC'; - eventsToRemember['settings.activeTimezone.edited']({ + eventsToRemember['settings.active_timezone.edited']({ attributes: {value: scope.newTimezone}, _updatedAttributes: {value: scope.oldTimezone} }); @@ -194,7 +194,7 @@ describe('Models: listeners', function () { })(); }); - it('activeTimezone changes from Amsterdam to Seoul', function (done) { + it('active_timezone changes from Amsterdam to Seoul', function (done) { var timeout; /** @@ -216,7 +216,7 @@ describe('Models: listeners', function () { scope.oldTimezone = 'Europe/Amsterdam'; scope.newTimezone = 'Asia/Seoul'; - eventsToRemember['settings.activeTimezone.edited']({ + eventsToRemember['settings.active_timezone.edited']({ attributes: {value: scope.newTimezone}, _updatedAttributes: {value: scope.oldTimezone} }); @@ -281,7 +281,7 @@ describe('Models: listeners', function () { scope.oldTimezone = 'Asia/Baghdad'; scope.newTimezone = 'Etc/UTC'; - eventsToRemember['settings.activeTimezone.edited']({ + eventsToRemember['settings.active_timezone.edited']({ attributes: {value: scope.newTimezone}, _updatedAttributes: {value: scope.oldTimezone} }); @@ -316,7 +316,7 @@ describe('Models: listeners', function () { describe('db has no scheduled posts', function () { it('no scheduled posts', function (done) { - eventsToRemember['settings.activeTimezone.edited']({ + eventsToRemember['settings.active_timezone.edited']({ attributes: {value: scope.newTimezone}, _updatedAttributes: {value: scope.oldTimezone} }); diff --git a/core/test/unit/controllers/frontend/index_spec.js b/core/test/unit/controllers/frontend/index_spec.js index db2132fc3c..e6a41643a6 100644 --- a/core/test/unit/controllers/frontend/index_spec.js +++ b/core/test/unit/controllers/frontend/index_spec.js @@ -18,7 +18,7 @@ describe('Frontend Controller', function () { function resetLocalSettingsCache() { localSettingsCache = { permalinks: '/:slug/', - activeTheme: 'casper' + active_theme: 'casper' }; } diff --git a/core/test/unit/controllers/frontend/templates_spec.js b/core/test/unit/controllers/frontend/templates_spec.js index ef6c09b9dc..46e85cfb91 100644 --- a/core/test/unit/controllers/frontend/templates_spec.js +++ b/core/test/unit/controllers/frontend/templates_spec.js @@ -70,14 +70,14 @@ describe('templates', function () { }); }); - it('returns fallback if there is no activeTheme', function () { + it('returns fallback if there is no active_theme', function () { getActiveThemeStub.returns(undefined); templates.pickTemplate(['tag-test', 'tag', 'index'], 'fallback').should.eql('fallback'); templates.pickTemplate(['page-my-post', 'page', 'post'], 'fallback').should.eql('fallback'); }); - it('returns fallback if activeTheme has no templates', function () { + it('returns fallback if active_theme has no templates', function () { templates.pickTemplate(['tag-test', 'tag', 'index'], 'fallback').should.eql('fallback'); templates.pickTemplate(['page-about', 'page', 'post'], 'fallback').should.eql('fallback'); }); @@ -232,7 +232,7 @@ describe('templates', function () { }); }); - it('will fall back to default if there is no activeTheme', function () { + it('will fall back to default if there is no active_theme', function () { getActiveThemeStub.returns(undefined); templates.error(500).should.match(/core\/server\/views\/error.hbs$/); diff --git a/core/test/unit/middleware/uncapitalise_spec.js b/core/test/unit/middleware/uncapitalise_spec.js index 795839905e..df1238cfcc 100644 --- a/core/test/unit/middleware/uncapitalise_spec.js +++ b/core/test/unit/middleware/uncapitalise_spec.js @@ -163,14 +163,14 @@ describe('Middleware: uncapitalise', function () { it('does not convert any capitals after the endpoint', function (done) { var query = '?filter=mAgic'; - req.path = '/Ghost/API/v0.1/settings/isPrivate/'; + req.path = '/Ghost/API/v0.1/settings/is_private/'; req.url = req.path + query; uncapitalise(req, res, next); next.called.should.be.false(); res.redirect.calledOnce.should.be.true(); - res.redirect.calledWith(301, '/ghost/api/v0.1/settings/isPrivate/?filter=mAgic').should.be.true(); + res.redirect.calledWith(301, '/ghost/api/v0.1/settings/is_private/?filter=mAgic').should.be.true(); done(); }); diff --git a/core/test/unit/server_helpers/body_class_spec.js b/core/test/unit/server_helpers/body_class_spec.js index a6f68a40ed..495da878ac 100644 --- a/core/test/unit/server_helpers/body_class_spec.js +++ b/core/test/unit/server_helpers/body_class_spec.js @@ -24,7 +24,7 @@ describe('{{body_class}} helper', function () { data: { root: { context: [], - settings: {activeTheme: 'casper'} + settings: {active_theme: 'casper'} } } }; diff --git a/core/test/unit/themes/middleware_spec.js b/core/test/unit/themes/middleware_spec.js index c5715f1b4b..d095cec722 100644 --- a/core/test/unit/themes/middleware_spec.js +++ b/core/test/unit/themes/middleware_spec.js @@ -36,7 +36,7 @@ describe('Themes', function () { beforeEach(function () { mountThemeSpy = sandbox.spy(); - settingsCacheStub.withArgs('activeTheme').returns('casper'); + settingsCacheStub.withArgs('active_theme').returns('casper'); }); it('mounts active theme if not yet mounted', function (done) { @@ -84,7 +84,7 @@ describe('Themes', function () { should.exist(err); err.message.should.eql('The currently active theme "casper" is missing.'); - settingsCacheStub.calledWith('activeTheme').should.be.true(); + settingsCacheStub.calledWith('active_theme').should.be.true(); getActiveThemeStub.called.should.be.true(); mountThemeSpy.called.should.be.false(); diff --git a/core/test/unit/utils/url_spec.js b/core/test/unit/utils/url_spec.js index 069c60aa29..2f78c95617 100644 --- a/core/test/unit/utils/url_spec.js +++ b/core/test/unit/utils/url_spec.js @@ -451,7 +451,7 @@ describe('Url', function () { }); it('permalink is /:year/:month/:day/:slug, blog timezone is Los Angeles', function () { - localSettingsCache.activeTimezone = 'America/Los_Angeles'; + localSettingsCache.active_timezone = 'America/Los_Angeles'; localSettingsCache.permalinks = '/:year/:month/:day/:slug/'; var testData = testUtils.DataGenerator.Content.posts[2], @@ -462,7 +462,7 @@ describe('Url', function () { }); it('permalink is /:year/:month/:day/:slug, blog timezone is Asia Tokyo', function () { - localSettingsCache.activeTimezone = 'Asia/Tokyo'; + localSettingsCache.active_timezone = 'Asia/Tokyo'; localSettingsCache.permalinks = '/:year/:month/:day/:slug/'; var testData = testUtils.DataGenerator.Content.posts[2], @@ -473,7 +473,7 @@ describe('Url', function () { }); it('post is page, no permalink usage allowed at all', function () { - localSettingsCache.activeTimezone = 'America/Los_Angeles'; + localSettingsCache.active_timezone = 'America/Los_Angeles'; localSettingsCache.permalinks = '/:year/:month/:day/:slug/'; var testData = testUtils.DataGenerator.Content.posts[5], @@ -483,7 +483,7 @@ describe('Url', function () { }); it('permalink is /:year/:id:/:author', function () { - localSettingsCache.activeTimezone = 'America/Los_Angeles'; + localSettingsCache.active_timezone = 'America/Los_Angeles'; localSettingsCache.permalinks = '/:year/:id/:author/'; var testData = _.merge(testUtils.DataGenerator.Content.posts[2], {id: 3}, {author: {slug: 'joe-blog'}}), @@ -494,7 +494,7 @@ describe('Url', function () { }); it('permalink is /:year/:id:/:author', function () { - localSettingsCache.activeTimezone = 'Europe/Berlin'; + localSettingsCache.active_timezone = 'Europe/Berlin'; localSettingsCache.permalinks = '/:year/:id/:author/'; var testData = _.merge(testUtils.DataGenerator.Content.posts[2], {id: 3}, {author: {slug: 'joe-blog'}}), @@ -505,7 +505,7 @@ describe('Url', function () { }); it('post is not published yet', function () { - localSettingsCache.activeTimezone = 'Europe/London'; + localSettingsCache.active_timezone = 'Europe/London'; localSettingsCache.permalinks = '/:year/:month/:day/:slug/'; var testData = _.merge(testUtils.DataGenerator.Content.posts[2], {id: 3, published_at: null}),