diff --git a/core/frontend/services/settings/index.js b/core/frontend/services/settings/index.js index 77cd6e7218..a4a8be01f4 100644 --- a/core/frontend/services/settings/index.js +++ b/core/frontend/services/settings/index.js @@ -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]; }, diff --git a/test/unit/services/settings/settings.test.js b/test/unit/services/settings/settings.test.js index d677b17348..4fa12855fd 100644 --- a/test/unit/services/settings/settings.test.js +++ b/test/unit/services/settings/settings.test.js @@ -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(); - } - }); - }); });