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() {
if (!this._loadingPromise) {
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) => {
this._loadingPromise = null;
return settings;

View File

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

View File

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