mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
3b90b1f335
refs https://github.com/TryGhost/Team/issues/807 The launch wizard completed flag was previously stored at per user level in accessibility column of user table, so an administrator still got the option to complete the launch wizard even if the owner had completed it previously, which is not expected pattern. This change moves the launch complete flag for Admin to common settings from per user level so a site only needs to complete the launch wizard once irrespective of which user completes it - adds new `editor_is_launch_complete` setting to track if a site launch steps are completed in Admin - adds new migration util to easily allow adding new setting - adds migration to introduce new `editor_is_launch_complete` setting - adds migration to update launch complete flag for a site if any of the users have already completed the launch steps
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
const should = require('should');
|
|
const testUtils = require('../../utils');
|
|
const db = require('../../../core/server/data/db');
|
|
|
|
// Stuff we are testing
|
|
const models = require('../../../core/server/models');
|
|
|
|
describe('Settings Model', function () {
|
|
before(models.init);
|
|
afterEach(testUtils.teardownDb);
|
|
|
|
describe('defaults', function () {
|
|
it('populates all defaults', async function () {
|
|
const settings = await models.Settings.findAll();
|
|
settings.length.should.equal(0);
|
|
|
|
await models.Settings.populateDefaults();
|
|
|
|
const settingsPopulated = await models.Settings.findAll();
|
|
settingsPopulated.length.should.equal(94);
|
|
});
|
|
|
|
it('doesn\'t overwrite any existing settings', async function () {
|
|
const now = db.knex.raw('CURRENT_TIMESTAMP');
|
|
await db.knex
|
|
.table('settings')
|
|
.insert({
|
|
id: 'test_id',
|
|
key: 'title',
|
|
value: 'Testing Defaults',
|
|
flags: 'PUBLIC',
|
|
type: 'string',
|
|
created_at: now,
|
|
created_by: 1,
|
|
updated_at: now,
|
|
updated_by: 1
|
|
});
|
|
|
|
const settings = await models.Settings.findAll();
|
|
settings.length.should.equal(1);
|
|
|
|
await models.Settings.populateDefaults();
|
|
|
|
const settingsPopulated = await models.Settings.findAll();
|
|
settingsPopulated.length.should.equal(94);
|
|
|
|
const titleSetting = settingsPopulated.models.find(s => s.get('key') === 'title');
|
|
titleSetting.get('value').should.equal('Testing Defaults');
|
|
|
|
const descriptionSetting = settingsPopulated.models.find(s => s.get('key') === 'description');
|
|
descriptionSetting.get('value').should.equal('Thoughts, stories and ideas');
|
|
});
|
|
});
|
|
});
|