post-scheduling: flat config for scheduling

This commit is contained in:
kirrg001 2016-06-14 13:49:40 +02:00
parent 2835ad2298
commit b5ebd0200b
4 changed files with 14 additions and 22 deletions

View File

@ -94,10 +94,10 @@ ConfigManager.prototype.set = function (config) {
defaultStorageAdapter = 'local-file-store',
defaultSchedulingAdapter = 'SchedulingDefault',
activeStorageAdapter,
activePostSchedulingAdapter,
activeSchedulingAdapter,
contentPath,
storagePath,
postSchedulingPath,
schedulingPath,
subdir,
assetHash;
@ -151,8 +151,7 @@ ConfigManager.prototype.set = function (config) {
// read scheduling adapter(s) from config file or attach default adapter
this._config.scheduling = this._config.scheduling || {};
this._config.scheduling.postScheduling = this._config.scheduling.postScheduling || {};
activePostSchedulingAdapter = this._config.scheduling.postScheduling.active || defaultSchedulingAdapter;
activeSchedulingAdapter = this._config.scheduling.active || defaultSchedulingAdapter;
// we support custom adapters located in content folder
if (activeStorageAdapter === defaultStorageAdapter) {
@ -161,10 +160,10 @@ ConfigManager.prototype.set = function (config) {
storagePath = path.join(contentPath, 'storage');
}
if (activePostSchedulingAdapter === defaultSchedulingAdapter) {
postSchedulingPath = path.join(corePath, '/server/scheduling/');
if (activeSchedulingAdapter === defaultSchedulingAdapter) {
schedulingPath = path.join(corePath, '/server/scheduling/');
} else {
postSchedulingPath = path.join(contentPath, '/scheduling/');
schedulingPath = path.join(contentPath, '/scheduling/');
}
_.merge(this._config, {
@ -193,10 +192,8 @@ ConfigManager.prototype.set = function (config) {
clientAssets: path.join(corePath, '/built/assets/')
},
scheduling: {
postScheduling: {
active: activePostSchedulingAdapter,
path: postSchedulingPath
}
active: activeSchedulingAdapter,
path: schedulingPath
},
storage: {
active: activeStorageAdapter

View File

@ -1,5 +1,4 @@
var _ = require('lodash'),
postScheduling = require(__dirname + '/post-scheduling');
var postScheduling = require(__dirname + '/post-scheduling');
/**
* scheduling modules:
@ -8,5 +7,5 @@ var _ = require('lodash'),
exports.init = function init(options) {
options = options || {};
return postScheduling.init(_.pick(options, 'postScheduling', 'apiUrl'));
return postScheduling.init(options);
};

View File

@ -36,10 +36,8 @@ _private.loadScheduledPosts = function () {
};
exports.init = function init(options) {
options = options || {};
var config = options.postScheduling,
apiUrl = options.apiUrl,
var config = options || {},
apiUrl = config.apiUrl,
adapter = null,
client = null;

View File

@ -64,8 +64,7 @@ describe('Scheduling: Post Scheduling', function () {
describe('success', function () {
it('will be scheduled', function (done) {
postScheduling.init({
apiUrl: scope.apiUrl,
postScheduling: {}
apiUrl: scope.apiUrl
}).then(function () {
scope.events['post.scheduled'](scope.post);
scope.adapter.schedule.called.should.eql(true);
@ -90,8 +89,7 @@ describe('Scheduling: Post Scheduling', function () {
];
postScheduling.init({
apiUrl: scope.apiUrl,
postScheduling: {}
apiUrl: scope.apiUrl
}).then(function () {
scope.adapter.reschedule.calledTwice.should.eql(true);
done();