🎨 Added url value to the Content API /settings/ endpoint (#10946)

closes https://github.com/TryGhost/Ghost/issues/10945

- adds the `url` property to the returned output manually because it's a config value rather than a settings value
This commit is contained in:
Kevin Ansfield 2019-07-24 11:12:07 +01:00 committed by GitHub
parent 805f3c7250
commit 1aa7e368a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,5 @@
const settingsCache = require('../../services/settings/cache');
const urlUtils = require('../../lib/url-utils');
module.exports = {
docName: 'settings',
@ -8,7 +9,9 @@ module.exports = {
query() {
// @TODO: decouple settings cache from API knowledge
// The controller fetches models (or cached models) and the API frame for the target API version formats the response.
return settingsCache.getPublic();
return Object.assign({}, settingsCache.getPublic(), {
url: urlUtils.urlFor('home', true)
});
}
}
};

View File

@ -43,7 +43,7 @@ describe('Settings Content API', function () {
// Verify we have the right keys for settings
settings.should.have.properties(_.values(publicSettings));
Object.keys(settings).length.should.equal(22);
Object.keys(settings).length.should.equal(23);
// Verify that we are returning the defaults for each value
_.forEach(settings, (value, key) => {
@ -60,6 +60,12 @@ describe('Settings Content API', function () {
return;
}
// `url` does not come from the settings cache
if (key === 'url') {
should(value).eql(`${config.get('url')}/`);
return;
}
let defaultKey = _.findKey(publicSettings, v => v === key);
let defaultValue = _.find(defaultSettings, setting => setting.key === defaultKey).defaultValue;