post-scheduling: flat config for scheduling
This commit is contained in:
parent
2835ad2298
commit
b5ebd0200b
@ -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
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user