mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Dropped support for labs setting parameter
refs https://github.com/TryGhost/Ghost/issues/10318 - `labs` setting is dropped from setting values as the use of JSON objec to sore settings has been deprecated - `labs` setting is no longer accepted as a paramter in the Settings API nor the impoprter. The value is ignored if present in the POST/PUT requests and returns 404 in case it is requested by key at `GET /settings/:key`
This commit is contained in:
parent
ea6d656457
commit
37ef40b46e
8 changed files with 159 additions and 7 deletions
|
@ -5,7 +5,8 @@ const settingsCache = require('../../../../../services/settings/cache');
|
||||||
|
|
||||||
const DEPRECATED_SETTINGS = [
|
const DEPRECATED_SETTINGS = [
|
||||||
'bulk_email_settings',
|
'bulk_email_settings',
|
||||||
'slack'
|
'slack',
|
||||||
|
'labs'
|
||||||
];
|
];
|
||||||
|
|
||||||
const deprecatedSupportedSettingsOneToManyMap = {
|
const deprecatedSupportedSettingsOneToManyMap = {
|
||||||
|
|
|
@ -5,7 +5,8 @@ const settingsCache = require('../../../../../services/settings/cache');
|
||||||
|
|
||||||
const DEPRECATED_SETTINGS = [
|
const DEPRECATED_SETTINGS = [
|
||||||
'bulk_email_settings',
|
'bulk_email_settings',
|
||||||
'slack'
|
'slack',
|
||||||
|
'labs'
|
||||||
];
|
];
|
||||||
|
|
||||||
const deprecatedSupportedSettingsOneToManyMap = {
|
const deprecatedSupportedSettingsOneToManyMap = {
|
||||||
|
|
|
@ -5,7 +5,8 @@ const settingsCache = require('../../../../../services/settings/cache');
|
||||||
|
|
||||||
const DEPRECATED_SETTINGS = [
|
const DEPRECATED_SETTINGS = [
|
||||||
'bulk_email_settings',
|
'bulk_email_settings',
|
||||||
'slack'
|
'slack',
|
||||||
|
'labs'
|
||||||
];
|
];
|
||||||
|
|
||||||
const deprecatedSupportedSettingsOneToManyMap = {
|
const deprecatedSupportedSettingsOneToManyMap = {
|
||||||
|
|
|
@ -142,6 +142,10 @@ describe('Settings API', function () {
|
||||||
key: 'lang',
|
key: 'lang',
|
||||||
value: 'ua'
|
value: 'ua'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'labs',
|
||||||
|
value: JSON.stringify({members: true})
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'timezone',
|
key: 'timezone',
|
||||||
value: 'Pacific/Auckland'
|
value: 'Pacific/Auckland'
|
||||||
|
@ -163,7 +167,8 @@ describe('Settings API', function () {
|
||||||
headers['x-cache-invalidate'].should.eql('/*');
|
headers['x-cache-invalidate'].should.eql('/*');
|
||||||
should.exist(putBody);
|
should.exist(putBody);
|
||||||
|
|
||||||
putBody.settings.length.should.equal(17);
|
// NOTE: -1 for ignored labs setting
|
||||||
|
putBody.settings.length.should.equal(settingToChange.settings.length - 1);
|
||||||
|
|
||||||
putBody.settings[0].key.should.eql('title');
|
putBody.settings[0].key.should.eql('title');
|
||||||
putBody.settings[0].value.should.eql(JSON.stringify(changedValue));
|
putBody.settings[0].value.should.eql(JSON.stringify(changedValue));
|
||||||
|
@ -213,8 +218,8 @@ describe('Settings API', function () {
|
||||||
putBody.settings[14].key.should.eql('timezone');
|
putBody.settings[14].key.should.eql('timezone');
|
||||||
should.equal(putBody.settings[14].value, 'Pacific/Auckland');
|
should.equal(putBody.settings[14].value, 'Pacific/Auckland');
|
||||||
|
|
||||||
putBody.settings[16].key.should.eql('slack');
|
putBody.settings[15].key.should.eql('slack');
|
||||||
should.equal(putBody.settings[16].value, JSON.stringify([{
|
should.equal(putBody.settings[15].value, JSON.stringify([{
|
||||||
url: 'https://overrides.tld',
|
url: 'https://overrides.tld',
|
||||||
username: 'New Slack Username'
|
username: 'New Slack Username'
|
||||||
}]));
|
}]));
|
||||||
|
|
|
@ -247,6 +247,21 @@ describe('Settings API (canary)', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can\'t read labs dropped in v4', function (done) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Can read deprecated default_locale', function (done) {
|
it('Can read deprecated default_locale', function (done) {
|
||||||
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
@ -460,6 +475,33 @@ describe('Settings API (canary)', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can\'t edit labs dropped in v4', function (done) {
|
||||||
|
const settingToChange = {
|
||||||
|
settings: [{key: 'labs', value: JSON.stringify({members: false})}]
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
|
should.exist(jsonResponse);
|
||||||
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
|
jsonResponse.settings.length.should.eql(0);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Can\'t edit non existent setting', function () {
|
it('Can\'t edit non existent setting', function () {
|
||||||
return request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
|
|
@ -253,6 +253,21 @@ describe('Settings API (v2)', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can\'t read labs dropped in v4', function (done) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Can read default_locale deprecated in v3', function (done) {
|
it('Can read default_locale deprecated in v3', function (done) {
|
||||||
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
@ -428,6 +443,33 @@ describe('Settings API (v2)', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can\'t edit labs dropped in v4', function (done) {
|
||||||
|
const settingToChange = {
|
||||||
|
settings: [{key: 'labs', value: JSON.stringify({members: false})}]
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
|
should.exist(jsonResponse);
|
||||||
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
|
jsonResponse.settings.length.should.eql(0);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Can\'t edit non existent setting', function () {
|
it('Can\'t edit non existent setting', function () {
|
||||||
return request.get(localUtils.API.getApiQuery('settings/'))
|
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
|
|
@ -270,6 +270,21 @@ describe('Settings API (v3)', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can\'t read labs dropped in v4', function (done) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Can read deprecated default_locale', function (done) {
|
it('Can read deprecated default_locale', function (done) {
|
||||||
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
@ -433,6 +448,33 @@ describe('Settings API (v3)', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Can\'t edit labs dropped in v4', function (done) {
|
||||||
|
const settingToChange = {
|
||||||
|
settings: [{key: 'labs', value: JSON.stringify({members: false})}]
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
const jsonResponse = res.body;
|
||||||
|
|
||||||
|
should.exist(jsonResponse);
|
||||||
|
should.exist(jsonResponse.settings);
|
||||||
|
|
||||||
|
jsonResponse.settings.length.should.eql(0);
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Can\'t read non existent setting', function (done) {
|
it('Can\'t read non existent setting', function (done) {
|
||||||
request.get(localUtils.API.getApiQuery('settings/testsetting/'))
|
request.get(localUtils.API.getApiQuery('settings/testsetting/'))
|
||||||
.set('Origin', config.get('url'))
|
.set('Origin', config.get('url'))
|
||||||
|
|
|
@ -113,7 +113,7 @@ const exportedLegacyBody = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Tests in here do an import for each test
|
// Tests in here do an import for each test
|
||||||
describe('Integration: Importer', function () {
|
describe.only('Integration: Importer', function () {
|
||||||
before(testUtils.teardownDb);
|
before(testUtils.teardownDb);
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
@ -912,6 +912,24 @@ describe('Integration: Importer', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not import settings: labs', function () {
|
||||||
|
const exportData = exportedLatestBody().db[0];
|
||||||
|
|
||||||
|
exportData.data.settings[0] = testUtils.DataGenerator.forKnex.createSetting({
|
||||||
|
key: 'labs',
|
||||||
|
value: JSON.stringify({members: true})
|
||||||
|
});
|
||||||
|
|
||||||
|
return dataImporter.doImport(exportData, importOptions)
|
||||||
|
.then(function (imported) {
|
||||||
|
imported.problems.length.should.eql(0);
|
||||||
|
return models.Settings.findOne(_.merge({key: 'labs'}, testUtils.context.internal));
|
||||||
|
})
|
||||||
|
.then(function (result) {
|
||||||
|
should.equal(result, null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('does not import settings: slack_url', function () {
|
it('does not import settings: slack_url', function () {
|
||||||
const exportData = exportedLatestBody().db[0];
|
const exportData = exportedLatestBody().db[0];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue