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