Updated to fetch settings using /settings/?group= instead of ?type=

refs https://github.com/TryGhost/Ghost/issues/10318

- primary change is in the settings service which is the only place we fetch the settings endpoint
- mocked APIs and fixture data updated to expect and to filter on `?group` rather than `?type`
This commit is contained in:
Kevin Ansfield 2020-06-24 14:23:51 +01:00
parent 195765b7e7
commit 8984c0ae32
4 changed files with 28 additions and 28 deletions

View File

@ -27,7 +27,7 @@ export default Service.extend(_ProxyMixin, ValidationEngine, {
_loadSettings() { _loadSettings() {
if (!this._loadingPromise) { if (!this._loadingPromise) {
this._loadingPromise = this.store this._loadingPromise = this.store
.queryRecord('setting', {type: 'site,theme,private,members,portal,email,amp,labs,slack,unsplash,views'}) .queryRecord('setting', {group: 'site,theme,private,members,portal,email,amp,labs,slack,unsplash,views'})
.then((settings) => { .then((settings) => {
this._loadingPromise = null; this._loadingPromise = null;
return settings; return settings;

View File

@ -1,20 +1,20 @@
export default function mockSettings(server) { export default function mockSettings(server) {
server.get('/settings/', function ({db}, {queryParams}) { server.get('/settings/', function ({db}, {queryParams}) {
let {type} = queryParams; let {group} = queryParams;
let filters = type.split(','); let filters = group.split(',');
let settings = []; let settings = [];
if (!db.settings.length) { if (!db.settings.length) {
server.loadFixtures('settings'); server.loadFixtures('settings');
} }
filters.forEach((type) => { filters.forEach((groupFilter) => {
settings.pushObjects(db.settings.where({type})); settings.pushObjects(db.settings.where({group: groupFilter}));
}); });
return { return {
settings, settings,
meta: {filters: {type}} meta: {filters: {group}}
}; };
}); });
@ -27,7 +27,7 @@ export default function mockSettings(server) {
if (db.settings.where({key}).length > 0) { if (db.settings.where({key}).length > 0) {
db.settings.update({key}, newSetting); db.settings.update({key}, newSetting);
} else { } else {
newSetting.type = newSetting.type || 'site'; newSetting.group = newSetting.group || 'site';
db.settings.insert(newSetting); db.settings.insert(newSetting);
} }
}); });

View File

@ -5,7 +5,7 @@ export default [
created_at: '2015-09-11T09:44:30.805Z', created_at: '2015-09-11T09:44:30.805Z',
created_by: 1, created_by: 1,
key: 'title', key: 'title',
type: 'site', group: 'site',
updated_at: '2015-10-04T16:26:05.195Z', updated_at: '2015-10-04T16:26:05.195Z',
updated_by: 1, updated_by: 1,
value: 'Test Blog' value: 'Test Blog'
@ -15,7 +15,7 @@ export default [
created_at: '2015-09-11T09:44:30.806Z', created_at: '2015-09-11T09:44:30.806Z',
created_by: 1, created_by: 1,
key: 'description', key: 'description',
type: 'site', group: 'site',
updated_at: '2015-10-04T16:26:05.198Z', updated_at: '2015-10-04T16:26:05.198Z',
updated_by: 1, updated_by: 1,
value: 'Thoughts, stories and ideas.' value: 'Thoughts, stories and ideas.'
@ -24,7 +24,7 @@ export default [
id: 3, id: 3,
key: 'logo', key: 'logo',
value: '/content/images/2013/Nov/logo.png', value: '/content/images/2013/Nov/logo.png',
type: 'site', group: 'site',
created_at: '2013-11-25T14:48:11.000Z', created_at: '2013-11-25T14:48:11.000Z',
created_by: 1, created_by: 1,
updated_at: '2015-10-27T17:39:58.273Z', updated_at: '2015-10-27T17:39:58.273Z',
@ -34,7 +34,7 @@ export default [
id: 4, id: 4,
key: 'cover_image', key: 'cover_image',
value: '/content/images/2014/Feb/cover.jpg', value: '/content/images/2014/Feb/cover.jpg',
type: 'site', group: 'site',
created_at: '2013-11-25T14:48:11.000Z', created_at: '2013-11-25T14:48:11.000Z',
created_by: 1, created_by: 1,
updated_at: '2015-10-27T17:39:58.276Z', updated_at: '2015-10-27T17:39:58.276Z',
@ -44,7 +44,7 @@ export default [
id: 5, id: 5,
key: 'default_locale', key: 'default_locale',
value: 'en', value: 'en',
type: 'site', group: 'site',
created_at: '2013-11-25T14:48:11.000Z', created_at: '2013-11-25T14:48:11.000Z',
created_by: 1, created_by: 1,
updated_at: '2015-10-27T17:39:58.278Z', updated_at: '2015-10-27T17:39:58.278Z',
@ -55,7 +55,7 @@ export default [
created_at: '2015-09-11T09:44:30.809Z', created_at: '2015-09-11T09:44:30.809Z',
created_by: 1, created_by: 1,
key: 'codeinjection_head', key: 'codeinjection_head',
type: 'site', group: 'site',
updated_at: '2015-09-23T13:32:49.858Z', updated_at: '2015-09-23T13:32:49.858Z',
updated_by: 1, updated_by: 1,
value: '' value: ''
@ -65,7 +65,7 @@ export default [
created_at: '2015-09-11T09:44:30.809Z', created_at: '2015-09-11T09:44:30.809Z',
created_by: 1, created_by: 1,
key: 'codeinjection_foot', key: 'codeinjection_foot',
type: 'site', group: 'site',
updated_at: '2015-09-23T13:32:49.858Z', updated_at: '2015-09-23T13:32:49.858Z',
updated_by: 1, updated_by: 1,
value: '' value: ''
@ -74,7 +74,7 @@ export default [
id: 12, id: 12,
key: 'labs', key: 'labs',
value: '{}', value: '{}',
type: 'labs', group: 'labs',
created_at: '2015-01-12T18:29:01.000Z', created_at: '2015-01-12T18:29:01.000Z',
created_by: 1, created_by: 1,
updated_at: '2015-10-27T17:39:58.288Z', updated_at: '2015-10-27T17:39:58.288Z',
@ -85,7 +85,7 @@ export default [
created_at: '2015-09-11T09:44:30.810Z', created_at: '2015-09-11T09:44:30.810Z',
created_by: 1, created_by: 1,
key: 'navigation', key: 'navigation',
type: 'site', group: 'site',
updated_at: '2015-09-23T13:32:49.868Z', updated_at: '2015-09-23T13:32:49.868Z',
updated_by: 1, updated_by: 1,
value: JSON.stringify([ value: JSON.stringify([
@ -98,7 +98,7 @@ export default [
created_at: '2015-09-11T09:44:30.810Z', created_at: '2015-09-11T09:44:30.810Z',
created_by: 1, created_by: 1,
key: 'is_private', key: 'is_private',
type: 'private', group: 'private',
updated_at: '2015-09-23T13:32:49.868Z', updated_at: '2015-09-23T13:32:49.868Z',
updated_by: 1, updated_by: 1,
value: false value: false
@ -108,7 +108,7 @@ export default [
created_at: '2015-09-11T09:44:30.810Z', created_at: '2015-09-11T09:44:30.810Z',
created_by: 1, created_by: 1,
key: 'password', key: 'password',
type: 'private', group: 'private',
updated_at: '2015-09-23T13:32:49.868Z', updated_at: '2015-09-23T13:32:49.868Z',
updated_by: 1, updated_by: 1,
value: '' value: ''
@ -118,7 +118,7 @@ export default [
created_at: '2016-05-05T15:04:03.115Z', created_at: '2016-05-05T15:04:03.115Z',
created_by: 1, created_by: 1,
key: 'slack', key: 'slack',
type: 'slack', group: 'slack',
updated_at: '2016-05-05T18:33:09.168Z', updated_at: '2016-05-05T18:33:09.168Z',
updated_by: 1, updated_by: 1,
value: '[{"url":"", "username":"Ghost"}]' value: '[{"url":"", "username":"Ghost"}]'
@ -128,7 +128,7 @@ export default [
created_at: '2016-05-05T15:40:12.133Z', created_at: '2016-05-05T15:40:12.133Z',
created_by: 1, created_by: 1,
key: 'facebook', key: 'facebook',
type: 'site', group: 'site',
updated_at: '2016-05-08T15:20:25.953Z', updated_at: '2016-05-08T15:20:25.953Z',
updated_by: 1, updated_by: 1,
value: 'test' value: 'test'
@ -138,7 +138,7 @@ export default [
created_at: '2016-05-05T15:40:12.134Z', created_at: '2016-05-05T15:40:12.134Z',
created_by: 1, created_by: 1,
key: 'twitter', key: 'twitter',
type: 'site', group: 'site',
updated_at: '2016-05-08T15:20:25.954Z', updated_at: '2016-05-08T15:20:25.954Z',
updated_by: 1, updated_by: 1,
value: '@test' value: '@test'
@ -148,7 +148,7 @@ export default [
created_at: '2015-09-11T09:44:30.810Z', created_at: '2015-09-11T09:44:30.810Z',
created_by: 1, created_by: 1,
key: 'active_timezone', key: 'active_timezone',
type: 'site', group: 'site',
updated_at: '2015-09-23T13:32:49.868Z', updated_at: '2015-09-23T13:32:49.868Z',
updated_by: 1, updated_by: 1,
value: 'Etc/UTC' value: 'Etc/UTC'
@ -158,7 +158,7 @@ export default [
created_at: '2017-01-09T08:40:59.000Z', created_at: '2017-01-09T08:40:59.000Z',
created_by: 1, created_by: 1,
key: 'amp', key: 'amp',
type: 'amp', group: 'amp',
updated_at: '2017-01-09T08:49:42.991Z', updated_at: '2017-01-09T08:49:42.991Z',
updated_by: 1, updated_by: 1,
value: 'true' value: 'true'
@ -167,7 +167,7 @@ export default [
id: 22, id: 22,
key: 'icon', key: 'icon',
value: '/content/images/2014/Feb/favicon.ico', value: '/content/images/2014/Feb/favicon.ico',
type: 'site', group: 'site',
created_at: '2013-11-25T14:48:11.000Z', created_at: '2013-11-25T14:48:11.000Z',
created_by: 1, created_by: 1,
updated_at: '2015-10-27T17:39:58.276Z', updated_at: '2015-10-27T17:39:58.276Z',
@ -175,7 +175,7 @@ export default [
}, },
{ {
id: 23, id: 23,
type: 'members', group: 'members',
key: 'members_subscription_settings', key: 'members_subscription_settings',
value: '{"allowSelfSignup":true,"fromAddress":"noreply","paymentProcessors":[{"adapter":"stripe","config":{"secret_token":"","public_token":"","product":{"name":"Ghost Subscription"},"plans":[{"name":"Monthly","currency":"usd","interval":"month","amount":""},{"name":"Yearly","currency":"usd","interval":"year","amount":""}]}}]}', value: '{"allowSelfSignup":true,"fromAddress":"noreply","paymentProcessors":[{"adapter":"stripe","config":{"secret_token":"","public_token":"","product":{"name":"Ghost Subscription"},"plans":[{"name":"Monthly","currency":"usd","interval":"month","amount":""},{"name":"Yearly","currency":"usd","interval":"year","amount":""}]}}]}',
created_at: '2019-10-09T09:49:00.000Z', created_at: '2019-10-09T09:49:00.000Z',
@ -185,7 +185,7 @@ export default [
}, },
{ {
id: 24, id: 24,
type: 'email', group: 'email',
key: 'bulk_email_settings', key: 'bulk_email_settings',
value: '{"provider":"mailgun","apiKey":"","domain":"","baseUrl":""}', value: '{"provider":"mailgun","apiKey":"","domain":"","baseUrl":""}',
created_at: '2019-10-09T09:49:00.000Z', created_at: '2019-10-09T09:49:00.000Z',
@ -196,7 +196,7 @@ export default [
{ {
id: 25, id: 25,
key: 'secondary_navigation', key: 'secondary_navigation',
type: 'site', group: 'site',
created_at: '2019-11-20T09:44:30.810Z', created_at: '2019-11-20T09:44:30.810Z',
created_by: 1, created_by: 1,
updated_at: '2019-11-20T13:32:49.868Z', updated_at: '2019-11-20T13:32:49.868Z',

View File

@ -171,7 +171,7 @@ describe('Acceptance: Content', function () {
it('can navigate to custom views', async function () { it('can navigate to custom views', async function () {
this.server.create('setting', { this.server.create('setting', {
type: 'site', group: 'site',
key: 'shared_views', key: 'shared_views',
value: JSON.stringify([{ value: JSON.stringify([{
route: 'posts', route: 'posts',