mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
1ecb837981
refs https://github.com/TryGhost/Toolbox/issues/292 - When version missmatch handling is done in Ghost we need to store the 'Accept-Version' header values that have been already processed in the past (to avoid sending notifications about the same mismatch multiple times) - The `version_notifications` will be storing an array with handled versions like so: `['v3.44', 'v4.23', 'v4.39']`. - The emailing logic and processing is slightly similar to how "notification" key is handled, that's why I've placed the definition of this new key close by.
54 lines
1.9 KiB
JavaScript
54 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(96);
|
|
});
|
|
|
|
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(96);
|
|
|
|
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');
|
|
});
|
|
});
|
|
});
|