mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Enabled 'labs' to be accepted as a value in Settings API
refs https://github.com/TryGhost/Team/issues/757 - As labs has been added back to the settings table the APIs are reverting back to accepting it as a value
This commit is contained in:
parent
49ba26373d
commit
8ab43b84d5
7 changed files with 113 additions and 87 deletions
|
@ -5,8 +5,7 @@ const settingsCache = require('../../../../../services/settings/cache');
|
|||
|
||||
const DEPRECATED_SETTINGS = [
|
||||
'bulk_email_settings',
|
||||
'slack',
|
||||
'labs'
|
||||
'slack'
|
||||
];
|
||||
|
||||
const deprecatedSupportedSettingsOneToManyMap = {
|
||||
|
|
|
@ -5,8 +5,7 @@ const settingsCache = require('../../../../../services/settings/cache');
|
|||
|
||||
const DEPRECATED_SETTINGS = [
|
||||
'bulk_email_settings',
|
||||
'slack',
|
||||
'labs'
|
||||
'slack'
|
||||
];
|
||||
|
||||
const deprecatedSupportedSettingsOneToManyMap = {
|
||||
|
|
|
@ -5,8 +5,7 @@ const settingsCache = require('../../../../../services/settings/cache');
|
|||
|
||||
const DEPRECATED_SETTINGS = [
|
||||
'bulk_email_settings',
|
||||
'slack',
|
||||
'labs'
|
||||
'slack'
|
||||
];
|
||||
|
||||
const deprecatedSupportedSettingsOneToManyMap = {
|
||||
|
|
|
@ -144,7 +144,7 @@ describe('Settings API', function () {
|
|||
},
|
||||
{
|
||||
key: 'labs',
|
||||
value: JSON.stringify({members: true})
|
||||
value: JSON.stringify({})
|
||||
},
|
||||
{
|
||||
key: 'timezone',
|
||||
|
@ -171,8 +171,7 @@ describe('Settings API', function () {
|
|||
headers['x-cache-invalidate'].should.eql('/*');
|
||||
should.exist(putBody);
|
||||
|
||||
// NOTE: -1 for ignored labs setting
|
||||
putBody.settings.length.should.equal(settingToChange.settings.length - 1);
|
||||
putBody.settings.length.should.equal(settingToChange.settings.length);
|
||||
|
||||
putBody.settings[0].key.should.eql('title');
|
||||
putBody.settings[0].value.should.eql(JSON.stringify(changedValue));
|
||||
|
@ -219,14 +218,17 @@ describe('Settings API', function () {
|
|||
putBody.settings[13].key.should.eql('lang');
|
||||
should.equal(putBody.settings[13].value, 'ua');
|
||||
|
||||
putBody.settings[14].key.should.eql('timezone');
|
||||
should.equal(putBody.settings[14].value, 'Pacific/Auckland');
|
||||
putBody.settings[14].key.should.eql('labs');
|
||||
should.equal(putBody.settings[14].value, JSON.stringify({}));
|
||||
|
||||
putBody.settings[15].key.should.eql('unsplash');
|
||||
should.equal(putBody.settings[15].value, false);
|
||||
putBody.settings[15].key.should.eql('timezone');
|
||||
should.equal(putBody.settings[15].value, 'Pacific/Auckland');
|
||||
|
||||
putBody.settings[16].key.should.eql('slack');
|
||||
should.equal(putBody.settings[16].value, JSON.stringify([{
|
||||
putBody.settings[16].key.should.eql('unsplash');
|
||||
should.equal(putBody.settings[16].value, false);
|
||||
|
||||
putBody.settings[17].key.should.eql('slack');
|
||||
should.equal(putBody.settings[17].value, JSON.stringify([{
|
||||
url: 'https://overrides.tld',
|
||||
username: 'New Slack Username'
|
||||
}]));
|
||||
|
|
|
@ -85,7 +85,8 @@ const defaultSettingsKeyTypes = [
|
|||
{key: 'oauth_client_id', type: 'oauth'},
|
||||
{key: 'oauth_client_secret', type: 'oauth'},
|
||||
{key: 'editor_default_email_recipients', type: 'editor'},
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'}
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'},
|
||||
{key: 'labs', type: 'blog'}
|
||||
];
|
||||
|
||||
describe('Settings API (canary)', function () {
|
||||
|
@ -320,19 +321,23 @@ describe('Settings API (canary)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can\'t read labs dropped in v4', function (done) {
|
||||
request.get(localUtils.API.getApiQuery('settings/labs/'))
|
||||
it('Can read labs', async function () {
|
||||
const res = await request.get(localUtils.API.getApiQuery('settings/labs/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(404)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
.expect(200);
|
||||
|
||||
done();
|
||||
});
|
||||
should.not.exist(res.headers['x-cache-invalidate']);
|
||||
const jsonResponse = res.body;
|
||||
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
|
||||
jsonResponse.settings.length.should.eql(1);
|
||||
testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'group', 'key', 'value', 'type', 'flags', 'created_at', 'updated_at']);
|
||||
jsonResponse.settings[0].key.should.eql('labs');
|
||||
jsonResponse.settings[0].value.should.eql(JSON.stringify({}));
|
||||
});
|
||||
|
||||
it('Can read deprecated default_locale', function (done) {
|
||||
|
@ -648,31 +653,35 @@ describe('Settings API (canary)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can\'t edit labs dropped in v4', function (done) {
|
||||
it('Can edit labs', async function () {
|
||||
const settingToChange = {
|
||||
settings: [{key: 'labs', value: JSON.stringify({members: false})}]
|
||||
settings: [{
|
||||
key: 'labs',
|
||||
value: JSON.stringify({
|
||||
matchHelper: true
|
||||
})
|
||||
}]
|
||||
};
|
||||
|
||||
request.put(localUtils.API.getApiQuery('settings/'))
|
||||
const res = await request.put(localUtils.API.getApiQuery('settings/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.send(settingToChange)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
.expect(200);
|
||||
|
||||
const jsonResponse = res.body;
|
||||
const jsonResponse = res.body;
|
||||
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
|
||||
jsonResponse.settings.length.should.eql(0);
|
||||
jsonResponse.settings.length.should.eql(1);
|
||||
testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'group', 'key', 'value', 'type', 'flags', 'created_at', 'updated_at']);
|
||||
jsonResponse.settings[0].key.should.eql('labs');
|
||||
|
||||
done();
|
||||
});
|
||||
jsonResponse.settings[0].value.should.eql(JSON.stringify({
|
||||
matchHelper: true
|
||||
}));
|
||||
});
|
||||
|
||||
it('Can\'t edit non existent setting', function () {
|
||||
|
|
|
@ -79,7 +79,8 @@ const defaultSettingsKeyTypes = [
|
|||
{key: 'oauth_client_id', type: 'oauth'},
|
||||
{key: 'oauth_client_secret', type: 'oauth'},
|
||||
{key: 'editor_default_email_recipients', type: 'editor'},
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'}
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'},
|
||||
{key: 'labs', type: 'blog'}
|
||||
];
|
||||
|
||||
describe('Settings API (v2)', function () {
|
||||
|
@ -264,19 +265,23 @@ describe('Settings API (v2)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can\'t read labs dropped in v4', function (done) {
|
||||
request.get(localUtils.API.getApiQuery('settings/labs/'))
|
||||
it('Can read labs', async function () {
|
||||
const res = await request.get(localUtils.API.getApiQuery('settings/labs/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(404)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
.expect(200);
|
||||
|
||||
done();
|
||||
});
|
||||
should.not.exist(res.headers['x-cache-invalidate']);
|
||||
const jsonResponse = res.body;
|
||||
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
|
||||
jsonResponse.settings.length.should.eql(1);
|
||||
testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'key', 'value', 'type', 'flags', 'created_at', 'updated_at']);
|
||||
jsonResponse.settings[0].key.should.eql('labs');
|
||||
jsonResponse.settings[0].value.should.eql(JSON.stringify({}));
|
||||
});
|
||||
|
||||
it('Can read default_locale deprecated in v3', function (done) {
|
||||
|
@ -516,31 +521,35 @@ describe('Settings API (v2)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can\'t edit labs dropped in v4', function (done) {
|
||||
it('Can edit labs', async function () {
|
||||
const settingToChange = {
|
||||
settings: [{key: 'labs', value: JSON.stringify({members: false})}]
|
||||
settings: [{
|
||||
key: 'labs',
|
||||
value: JSON.stringify({
|
||||
matchHelper: true
|
||||
})
|
||||
}]
|
||||
};
|
||||
|
||||
request.put(localUtils.API.getApiQuery('settings/'))
|
||||
const res = await request.put(localUtils.API.getApiQuery('settings/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.send(settingToChange)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
.expect(200);
|
||||
|
||||
const jsonResponse = res.body;
|
||||
const jsonResponse = res.body;
|
||||
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
|
||||
jsonResponse.settings.length.should.eql(0);
|
||||
jsonResponse.settings.length.should.eql(1);
|
||||
testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'key', 'value', 'type', 'flags', 'created_at', 'updated_at']);
|
||||
jsonResponse.settings[0].key.should.eql('labs');
|
||||
|
||||
done();
|
||||
});
|
||||
jsonResponse.settings[0].value.should.eql(JSON.stringify({
|
||||
matchHelper: true
|
||||
}));
|
||||
});
|
||||
|
||||
it('Can\'t edit non existent setting', function () {
|
||||
|
|
|
@ -83,7 +83,8 @@ const defaultSettingsKeyTypes = [
|
|||
{key: 'oauth_client_id', type: 'oauth'},
|
||||
{key: 'oauth_client_secret', type: 'oauth'},
|
||||
{key: 'editor_default_email_recipients', type: 'editor'},
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'}
|
||||
{key: 'editor_default_email_recipients_filter', type: 'editor'},
|
||||
{key: 'labs', type: 'blog'}
|
||||
];
|
||||
|
||||
describe('Settings API (v3)', function () {
|
||||
|
@ -281,19 +282,23 @@ describe('Settings API (v3)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can\'t read labs dropped in v4', function (done) {
|
||||
request.get(localUtils.API.getApiQuery('settings/labs/'))
|
||||
it('Can read labs', async function () {
|
||||
const res = await request.get(localUtils.API.getApiQuery('settings/labs/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(404)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
.expect(200);
|
||||
|
||||
done();
|
||||
});
|
||||
should.not.exist(res.headers['x-cache-invalidate']);
|
||||
const jsonResponse = res.body;
|
||||
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
|
||||
jsonResponse.settings.length.should.eql(1);
|
||||
testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'group', 'key', 'value', 'type', 'flags', 'created_at', 'updated_at']);
|
||||
jsonResponse.settings[0].key.should.eql('labs');
|
||||
jsonResponse.settings[0].value.should.eql(JSON.stringify({}));
|
||||
});
|
||||
|
||||
it('Can read deprecated default_locale', function (done) {
|
||||
|
@ -459,31 +464,35 @@ describe('Settings API (v3)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('Can\'t edit labs dropped in v4', function (done) {
|
||||
it('Can edit labs', async function () {
|
||||
const settingToChange = {
|
||||
settings: [{key: 'labs', value: JSON.stringify({members: false})}]
|
||||
settings: [{
|
||||
key: 'labs',
|
||||
value: JSON.stringify({
|
||||
matchHelper: true
|
||||
})
|
||||
}]
|
||||
};
|
||||
|
||||
request.put(localUtils.API.getApiQuery('settings/'))
|
||||
const res = await request.put(localUtils.API.getApiQuery('settings/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.send(settingToChange)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200)
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
.expect(200);
|
||||
|
||||
const jsonResponse = res.body;
|
||||
const jsonResponse = res.body;
|
||||
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
should.exist(jsonResponse);
|
||||
should.exist(jsonResponse.settings);
|
||||
|
||||
jsonResponse.settings.length.should.eql(0);
|
||||
jsonResponse.settings.length.should.eql(1);
|
||||
testUtils.API.checkResponseValue(jsonResponse.settings[0], ['id', 'group', 'key', 'value', 'type', 'flags', 'created_at', 'updated_at']);
|
||||
jsonResponse.settings[0].key.should.eql('labs');
|
||||
|
||||
done();
|
||||
});
|
||||
jsonResponse.settings[0].value.should.eql(JSON.stringify({
|
||||
matchHelper: true
|
||||
}));
|
||||
});
|
||||
|
||||
it('Can\'t read non existent setting', function (done) {
|
||||
|
|
Loading…
Add table
Reference in a new issue