2013-12-28 17:53:05 +00:00
|
|
|
var should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
2014-08-17 06:17:23 +00:00
|
|
|
Promise = require('bluebird'),
|
2016-06-20 14:47:53 +02:00
|
|
|
moment = require('moment'),
|
2013-12-28 17:53:05 +00:00
|
|
|
path = require('path'),
|
2014-08-23 12:19:13 -04:00
|
|
|
fs = require('fs'),
|
2014-02-05 00:40:30 -08:00
|
|
|
_ = require('lodash'),
|
2013-12-28 17:53:05 +00:00
|
|
|
|
2016-10-18 10:04:44 +02:00
|
|
|
testUtils = require('../../utils'),
|
|
|
|
i18n = require('../../../server/i18n'),
|
|
|
|
utils = require('../../../server/utils'),
|
2016-06-10 10:59:38 +02:00
|
|
|
/*jshint unused:false*/
|
2016-10-18 10:04:44 +02:00
|
|
|
db = require('../../../server/data/db/connection'),
|
2014-01-03 00:37:21 +00:00
|
|
|
|
2013-12-28 17:53:05 +00:00
|
|
|
// Thing we are testing
|
2016-10-18 10:04:44 +02:00
|
|
|
configUtils = require('../../utils/configUtils'),
|
2016-10-11 14:53:52 +02:00
|
|
|
config = configUtils.config;
|
2016-06-10 10:59:38 +02:00
|
|
|
|
2015-11-12 13:29:45 +01:00
|
|
|
i18n.init();
|
2014-06-04 22:26:03 +01:00
|
|
|
|
2013-12-26 12:15:10 +00:00
|
|
|
describe('Config', function () {
|
2016-04-13 11:10:40 -05:00
|
|
|
before(function () {
|
|
|
|
configUtils.restore();
|
|
|
|
});
|
|
|
|
|
2015-12-14 20:05:11 +00:00
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
2014-12-14 11:31:00 +00:00
|
|
|
});
|
|
|
|
|
2013-12-26 12:15:10 +00:00
|
|
|
describe('Theme', function () {
|
2014-09-02 23:15:15 -04:00
|
|
|
beforeEach(function () {
|
2015-12-14 20:05:11 +00:00
|
|
|
configUtils.set({
|
2014-09-02 23:15:15 -04:00
|
|
|
url: 'http://my-ghost-blog.com',
|
|
|
|
theme: {
|
|
|
|
title: 'casper',
|
|
|
|
description: 'casper',
|
|
|
|
logo: 'casper',
|
2016-08-22 17:56:35 +02:00
|
|
|
cover: 'casper',
|
|
|
|
timezone: 'Etc/UTC'
|
2014-09-02 23:15:15 -04:00
|
|
|
}
|
2013-12-26 12:15:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-12-28 16:01:08 +00:00
|
|
|
it('should have exactly the right keys', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var themeConfig = config.get('theme');
|
2013-12-26 12:15:10 +00:00
|
|
|
|
|
|
|
// This will fail if there are any extra keys
|
2016-09-13 22:13:52 +02:00
|
|
|
themeConfig.should.have.keys('title', 'description', 'logo', 'cover', 'timezone');
|
2013-12-28 16:01:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have the correct values for each key', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var themeConfig = config.get('theme');
|
2013-12-26 12:15:10 +00:00
|
|
|
|
|
|
|
// Check values are as we expect
|
|
|
|
themeConfig.should.have.property('title', 'casper');
|
|
|
|
themeConfig.should.have.property('description', 'casper');
|
|
|
|
themeConfig.should.have.property('logo', 'casper');
|
|
|
|
themeConfig.should.have.property('cover', 'casper');
|
2016-08-22 17:56:35 +02:00
|
|
|
themeConfig.should.have.property('timezone', 'Etc/UTC');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Timezone default', function () {
|
|
|
|
it('should use timezone from settings when set', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var themeConfig = config.get('theme');
|
2016-08-22 17:56:35 +02:00
|
|
|
|
|
|
|
// Check values are as we expect
|
|
|
|
themeConfig.should.have.property('timezone', 'Etc/UTC');
|
|
|
|
|
|
|
|
configUtils.set({
|
|
|
|
theme: {
|
|
|
|
timezone: 'Africa/Cairo'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-09-13 22:13:52 +02:00
|
|
|
config.get('theme').should.have.property('timezone', 'Africa/Cairo');
|
2016-08-22 17:56:35 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should set theme object with timezone by default', function () {
|
|
|
|
var themeConfig = configUtils.defaultConfig;
|
|
|
|
|
|
|
|
// Check values are as we expect
|
|
|
|
themeConfig.should.have.property('theme');
|
|
|
|
themeConfig.theme.should.have.property('timezone', 'Etc/UTC');
|
2013-12-26 12:15:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-01-05 01:40:53 -05:00
|
|
|
describe('Index', function () {
|
2013-12-28 16:01:08 +00:00
|
|
|
it('should have exactly the right keys', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var pathConfig = config.get('paths');
|
2013-12-28 16:01:08 +00:00
|
|
|
|
|
|
|
// This will fail if there are any extra keys
|
|
|
|
pathConfig.should.have.keys(
|
|
|
|
'appRoot',
|
2016-09-13 22:24:57 +02:00
|
|
|
'internalStoragePath',
|
|
|
|
'internalSchedulingPath',
|
2013-12-28 16:01:08 +00:00
|
|
|
'contentPath',
|
|
|
|
'corePath',
|
2016-04-14 18:32:43 +01:00
|
|
|
'internalAppPath',
|
2013-12-28 16:01:08 +00:00
|
|
|
'imagesRelPath',
|
|
|
|
'adminViews',
|
|
|
|
'helperTemplates',
|
2015-03-08 11:09:57 -06:00
|
|
|
'clientAssets'
|
2013-12-28 16:01:08 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have the correct values for each key', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var pathConfig = config.get('paths'),
|
2016-10-18 10:04:44 +02:00
|
|
|
appRoot = path.resolve(__dirname, '../../../../');
|
2013-12-28 16:01:08 +00:00
|
|
|
|
|
|
|
pathConfig.should.have.property('appRoot', appRoot);
|
2016-10-18 10:04:44 +02:00
|
|
|
pathConfig.should.have.property('imagesRelPath', 'content/images');
|
2016-01-11 12:37:59 +01:00
|
|
|
});
|
|
|
|
|
2014-02-08 10:41:15 -05:00
|
|
|
it('should allow specific properties to be user defined', function () {
|
2016-09-13 22:20:21 +02:00
|
|
|
var contentPath = path.join(config.get('paths').appRoot, 'otherContent', '/');
|
2014-01-05 01:40:53 -05:00
|
|
|
|
2016-09-13 22:24:57 +02:00
|
|
|
configUtils.set('paths:contentPath', contentPath);
|
2016-09-13 21:45:05 +02:00
|
|
|
config.get('paths').should.have.property('contentPath', contentPath);
|
2016-09-13 22:24:57 +02:00
|
|
|
config.getContentPath('images').should.eql(contentPath + 'images/');
|
2013-12-28 16:01:08 +00:00
|
|
|
});
|
|
|
|
});
|
2014-01-03 00:37:21 +00:00
|
|
|
|
2015-01-17 20:54:56 -07:00
|
|
|
describe('Storage', function () {
|
|
|
|
it('should default to local-file-store', function () {
|
2016-09-13 22:24:57 +02:00
|
|
|
config.get('paths').should.have.property('internalStoragePath', path.join(config.get('paths').corePath, '/server/storage/'));
|
2015-01-17 20:54:56 -07:00
|
|
|
|
2016-09-13 21:45:05 +02:00
|
|
|
config.get('storage').should.have.property('active', {
|
2016-08-22 19:55:28 +02:00
|
|
|
images: 'local-file-store',
|
|
|
|
themes: 'local-file-store'
|
|
|
|
});
|
2015-01-17 20:54:56 -07:00
|
|
|
});
|
|
|
|
|
2016-09-13 21:47:36 +02:00
|
|
|
it('no effect: setting a custom active storage as string', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var storagePath = path.join(config.get('paths').contentPath, 'storage', 's3');
|
2015-01-17 20:54:56 -07:00
|
|
|
|
2015-12-14 20:05:11 +00:00
|
|
|
configUtils.set({
|
2015-01-17 20:54:56 -07:00
|
|
|
storage: {
|
|
|
|
active: 's3',
|
|
|
|
s3: {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-09-13 21:47:36 +02:00
|
|
|
config.get('storage').should.have.property('active', 's3');
|
2016-09-13 21:45:05 +02:00
|
|
|
config.get('storage').should.have.property('s3', {});
|
2015-01-17 20:54:56 -07:00
|
|
|
});
|
2016-08-22 19:55:28 +02:00
|
|
|
|
2016-09-13 21:47:36 +02:00
|
|
|
it('able to set storage for themes (but not officially supported!)', function () {
|
2016-08-22 19:55:28 +02:00
|
|
|
configUtils.set({
|
|
|
|
storage: {
|
|
|
|
active: {
|
2016-09-13 21:47:36 +02:00
|
|
|
images: 'local-file-store',
|
2016-08-22 19:55:28 +02:00
|
|
|
themes: 's3'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-09-13 17:41:14 +02:00
|
|
|
config.get('storage').should.have.property('active', {
|
2016-08-22 19:55:28 +02:00
|
|
|
images: 'local-file-store',
|
2016-09-13 21:47:36 +02:00
|
|
|
themes: 's3'
|
2016-08-22 19:55:28 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow setting a custom active storage as object', function () {
|
2016-09-13 17:41:14 +02:00
|
|
|
var storagePath = path.join(config.get('paths').contentPath, 'storage', 's3');
|
2016-08-22 19:55:28 +02:00
|
|
|
|
|
|
|
configUtils.set({
|
|
|
|
storage: {
|
|
|
|
active: {
|
|
|
|
images: 's2',
|
2016-08-23 14:07:25 +02:00
|
|
|
themes: 'local-file-store'
|
2016-08-22 19:55:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-09-13 17:41:14 +02:00
|
|
|
config.get('storage').should.have.property('active', {
|
2016-08-22 19:55:28 +02:00
|
|
|
images: 's2',
|
2016-08-23 14:07:25 +02:00
|
|
|
themes: 'local-file-store'
|
2016-08-22 19:55:28 +02:00
|
|
|
});
|
|
|
|
});
|
2015-01-17 20:54:56 -07:00
|
|
|
});
|
2014-09-10 00:06:24 -04:00
|
|
|
});
|