Merge pull request #6981 from kirrg001/fix/default-tz-in-config

fix: put default timezone into config
This commit is contained in:
Hannah Wolfe 2016-06-13 18:49:17 +01:00 committed by GitHub
commit ecd77dd32f
3 changed files with 17 additions and 9 deletions

View File

@ -61,7 +61,7 @@ updateConfigCache = function () {
permalinks: (settingsCache.permalinks && settingsCache.permalinks.value) || '/:slug/',
twitter: (settingsCache.twitter && settingsCache.twitter.value) || '',
facebook: (settingsCache.facebook && settingsCache.facebook.value) || '',
timezone: (settingsCache.activeTimezone && settingsCache.activeTimezone.value) || 'Europe/Dublin'
timezone: (settingsCache.activeTimezone && settingsCache.activeTimezone.value) || config.theme.timezone
},
labs: labsValue
});

View File

@ -184,7 +184,10 @@ ConfigManager.prototype.set = function (config) {
},
theme: {
// normalise the URL by removing any trailing slash
url: this._config.url ? this._config.url.replace(/\/$/, '') : ''
url: this._config.url ? this._config.url.replace(/\/$/, '') : '',
// default timezone
timezone: 'Etc/UTC'
},
routeKeywords: {
tag: 'tag',

View File

@ -45,7 +45,7 @@ describe('Config', function () {
var themeConfig = config.theme;
// This will fail if there are any extra keys
themeConfig.should.have.keys('url', 'title', 'description', 'logo', 'cover');
themeConfig.should.have.keys('url', 'title', 'description', 'logo', 'cover', 'timezone');
});
it('should have the correct values for each key', function () {
@ -393,8 +393,8 @@ describe('Config', function () {
});
describe('urlPathForPost', function () {
it('permalink is /:slug/', function () {
configUtils.set({theme: {permalinks: '/:slug/', timezone: 'Europe/Dublin'}});
it('permalink is /:slug/, timezone is default', function () {
config.theme.permalinks = '/:slug/';
var testData = testUtils.DataGenerator.Content.posts[2],
postLink = '/short-and-sweet/';
@ -403,7 +403,9 @@ describe('Config', function () {
});
it('permalink is /:year/:month/:day/:slug, blog timezone is Los Angeles', function () {
configUtils.set({theme: {permalinks: '/:year/:month/:day/:slug/', timezone: 'America/Los_Angeles'}});
config.theme.timezone = 'America/Los_Angeles';
config.theme.permalinks = '/:year/:month/:day/:slug/';
var testData = testUtils.DataGenerator.Content.posts[2],
postLink = '/2016/05/17/short-and-sweet/';
@ -412,7 +414,8 @@ describe('Config', function () {
});
it('post is page, no permalink usage allowed at all', function () {
configUtils.set({theme: {permalinks: '/:year/:month/:day/:slug/', timezone: 'America/Los_Angeles'}});
config.theme.timezone = 'America/Los_Angeles';
config.theme.permalinks = '/:year/:month/:day/:slug/';
var testData = testUtils.DataGenerator.Content.posts[5],
postLink = '/static-page-test/';
@ -421,7 +424,8 @@ describe('Config', function () {
});
it('permalink is /:year/:id:/:author', function () {
configUtils.set({theme: {permalinks: '/:year/:id/:author/', timezone: 'America/Los_Angeles'}});
config.theme.timezone = 'America/Los_Angeles';
config.theme.permalinks = '/:year/:id/:author/';
var testData = _.merge(testUtils.DataGenerator.Content.posts[2], {id: 3}, {author: {slug: 'joe-blog'}}),
postLink = '/2015/3/joe-blog/';
@ -431,7 +435,8 @@ describe('Config', function () {
});
it('permalink is /:year/:id:/:author', function () {
configUtils.set({theme: {permalinks: '/:year/:id/:author/', timezone: 'Europe/Berlin'}});
config.theme.timezone = 'Europe/Berlin';
config.theme.permalinks = '/:year/:id/:author/';
var testData = _.merge(testUtils.DataGenerator.Content.posts[2], {id: 3}, {author: {slug: 'joe-blog'}}),
postLink = '/2016/3/joe-blog/';