mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03: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
@ -5,7 +5,8 @@ const settingsCache = require('../../../../../services/settings/cache');
|
||||
|
||||
const DEPRECATED_SETTINGS = [
|
||||
'bulk_email_settings',
|
||||
'slack'
|
||||
'slack',
|
||||
'labs'
|
||||
];
|
||||
|
||||
const deprecatedSupportedSettingsOneToManyMap = {
|
||||
|
@ -5,7 +5,8 @@ const settingsCache = require('../../../../../services/settings/cache');
|
||||
|
||||
const DEPRECATED_SETTINGS = [
|
||||
'bulk_email_settings',
|
||||
'slack'
|
||||
'slack',
|
||||
'labs'
|
||||
];
|
||||
|
||||
const deprecatedSupportedSettingsOneToManyMap = {
|
||||
|
@ -5,7 +5,8 @@ const settingsCache = require('../../../../../services/settings/cache');
|
||||
|
||||
const DEPRECATED_SETTINGS = [
|
||||
'bulk_email_settings',
|
||||
'slack'
|
||||
'slack',
|
||||
'labs'
|
||||
];
|
||||
|
||||
const deprecatedSupportedSettingsOneToManyMap = {
|
||||
|
@ -142,6 +142,10 @@ describe('Settings API', function () {
|
||||
key: 'lang',
|
||||
value: 'ua'
|
||||
},
|
||||
{
|
||||
key: 'labs',
|
||||
value: JSON.stringify({members: true})
|
||||
},
|
||||
{
|
||||
key: 'timezone',
|
||||
value: 'Pacific/Auckland'
|
||||
@ -163,7 +167,8 @@ describe('Settings API', function () {
|
||||
headers['x-cache-invalidate'].should.eql('/*');
|
||||
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].value.should.eql(JSON.stringify(changedValue));
|
||||
@ -213,8 +218,8 @@ describe('Settings API', function () {
|
||||
putBody.settings[14].key.should.eql('timezone');
|
||||
should.equal(putBody.settings[14].value, 'Pacific/Auckland');
|
||||
|
||||
putBody.settings[16].key.should.eql('slack');
|
||||
should.equal(putBody.settings[16].value, JSON.stringify([{
|
||||
putBody.settings[15].key.should.eql('slack');
|
||||
should.equal(putBody.settings[15].value, JSON.stringify([{
|
||||
url: 'https://overrides.tld',
|
||||
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) {
|
||||
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
||||
.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 () {
|
||||
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||
.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) {
|
||||
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
||||
.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 () {
|
||||
return request.get(localUtils.API.getApiQuery('settings/'))
|
||||
.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) {
|
||||
request.get(localUtils.API.getApiQuery('settings/default_locale/'))
|
||||
.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) {
|
||||
request.get(localUtils.API.getApiQuery('settings/testsetting/'))
|
||||
.set('Origin', config.get('url'))
|
||||
|
@ -113,7 +113,7 @@ const exportedLegacyBody = () => {
|
||||
};
|
||||
|
||||
// Tests in here do an import for each test
|
||||
describe('Integration: Importer', function () {
|
||||
describe.only('Integration: Importer', function () {
|
||||
before(testUtils.teardownDb);
|
||||
|
||||
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 () {
|
||||
const exportData = exportedLatestBody().db[0];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user