0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Removed unused getAll settings method

refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings

- The getAll function was never used. No need to keep it around!
This commit is contained in:
Naz 2021-09-23 13:31:56 +02:00 committed by naz
parent 71e2a06b25
commit 010db90a51
2 changed files with 0 additions and 88 deletions

View file

@ -60,36 +60,6 @@ module.exports = {
return SettingsLoader(setting);
},
/**
* Getter for all YAML settings.
* Example: `settings.getAll().then(...)`
* will return an Object like this (assuming we're supporting `routes`
* and `globals`):
* {
* routes: {
* routes: null,
* collections: { '/': [Object] },
* resources: { tag: '/tag/{slug}/', author: '/author/{slug}/' }
* },
* globals: {
* config: { url: 'testblog.com' }
* }
* }
* @returns {Object} settingsObject
* @description Returns all settings object as defined per YAML files in
* `/content/settings` directory.
*/
getAll: function getAll() {
const knownSettings = this.knownSettings();
const settingsToReturn = {};
_.each(knownSettings, function (setting) {
settingsToReturn[setting] = SettingsLoader(setting);
});
return settingsToReturn;
},
getDefaulHash: (setting) => {
return defaultHashes[setting];
},

View file

@ -76,62 +76,4 @@ describe('UNIT > Settings Service:', function () {
}
});
});
describe('getAll', function () {
let settingsLoaderStub;
let knownSettingsStub;
const settingsStubFile1 = {
routes: null,
collections: {
'/': {
permalink: '/{slug}/',
template: ['home', 'index']
}
},
resources: {tag: '/tag/{slug}/', author: '/author/{slug}/'}
};
const settingsStubFile2 = {
config: {
url: 'https://testblog.com'
}
};
beforeEach(function () {
knownSettingsStub = sinon.stub().returns(['routes', 'globals']);
settings.__set__('this.knownSettings', knownSettingsStub);
settingsLoaderStub = sinon.stub();
});
it('returns settings object for all known settings', function () {
settingsLoaderStub.onFirstCall().returns(settingsStubFile1);
settingsLoaderStub.onSecondCall().returns(settingsStubFile2);
settings.__set__('SettingsLoader', settingsLoaderStub);
const result = settings.getAll();
should.exist(result);
result.should.be.an.Object().with.properties('routes', 'globals');
result.routes.should.be.an.Object().with.properties('routes', 'collections', 'resources');
result.globals.should.be.an.Object().with.properties('config');
settingsLoaderStub.calledTwice.should.be.true();
});
it('passes SettinsLoader error through', function (done) {
settingsLoaderStub.onFirstCall().returns(settingsStubFile1);
settingsLoaderStub.onSecondCall().throws(new errors.GhostError({message: 'oops'}));
settings.__set__('SettingsLoader', settingsLoaderStub);
try {
settings.getAll();
done(new Error('SettingsLoader should fail'));
} catch (err) {
should.exist(err);
err.message.should.be.eql('oops');
settingsLoaderStub.calledTwice.should.be.true();
done();
}
});
});
});