0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

improvement: set activeTimezone when transforming dates (#7142)

no issue
- sets `settings.activeTimezone` to best-guess based on current server time when performing the timezones migration in order to prevent unexpected changes in timezone when upgrading
This commit is contained in:
Katharina Irrgang 2016-07-26 13:05:39 +02:00 committed by Kevin Ansfield
parent c9dc367bf0
commit e5a0471c9d
2 changed files with 8 additions and 8 deletions

View file

@ -186,6 +186,13 @@ module.exports = function transformDatesIntoUTC(options, logger) {
});
});
},
function setActiveTimezone() {
var timezone = config.forceTimezoneOnMigration || moment.tz.guess();
return models.Settings.edit({
key: 'activeTimezone',
value: timezone
}, options);
},
function addMigrationSettingsEntry() {
settingsMigrations[settingsKey] = moment().format();
return models.Settings.edit({

View file

@ -1018,6 +1018,7 @@ describe('Fixtures', function () {
serverTimezoneOffset = -60;
migrationsSettingsValue = '{}';
// stub for checkIfMigrationAlreadyRan
sandbox.stub(models.Settings.prototype, 'fetch', function () {
// CASE: we update migrations settings entry
if (this.get('key') === 'migrations') {
@ -1028,14 +1029,6 @@ describe('Fixtures', function () {
return Promise.resolve(newModels[Number(this.get('key'))]);
});
sandbox.stub(models.Base.Model.prototype, 'save', function (data) {
if (data.key !== 'migrations') {
should.exist(data.created_at);
}
return Promise.resolve({});
});
_.each(['Post', 'User', 'Subscriber', 'Settings', 'Role', 'Permission', 'Tag', 'App', 'AppSetting', 'AppField', 'Client'], function (modelType) {
sandbox.stub(models[modelType], 'findAll', function () {
var model = models[modelType].forge();