mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 09:52:09 +03:00
bc97de5fe9
no issue - provide a single point for accessing config in unit tests - create a single way to set and restore config - ensure that restore deletes top level optional keys that are now undefined - use this._config in check deprecations, otherwise the config gets cached - solves issues with interdependent tests
27 lines
747 B
JavaScript
27 lines
747 B
JavaScript
var _ = require('lodash'),
|
|
config = require('../../server/config'),
|
|
origConfig = _.cloneDeep(config),
|
|
|
|
configUtils = {};
|
|
|
|
configUtils.config = config;
|
|
configUtils.defaultConfig = _.cloneDeep(config.get());
|
|
|
|
configUtils.set = function (newConfig) {
|
|
config.set(newConfig);
|
|
};
|
|
|
|
configUtils.restore = function () {
|
|
var topLevelOptional = ['mail', 'updateCheck', 'storage', 'forceAdminSSL', 'urlSSL', 'compress', 'privacy'];
|
|
|
|
config.set(_.merge({}, origConfig, configUtils.defaultConfig));
|
|
// @TODO make this horror go away
|
|
_.each(topLevelOptional, function (option) {
|
|
if (origConfig[option] === undefined) {
|
|
delete config[option];
|
|
}
|
|
});
|
|
};
|
|
|
|
module.exports = configUtils;
|