From 80c797c6c2dcba7575baf63162f0db576c1781d1 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Tue, 14 Jun 2016 14:15:38 +0200 Subject: [PATCH] post-scheduling: forward UTC timestamp to scheduler adapters --- core/server/scheduling/post-scheduling/index.js | 4 ++-- core/test/integration/api/api_schedules_spec.js | 5 ++--- core/test/unit/scheduling/post-scheduling/index_spec.js | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/server/scheduling/post-scheduling/index.js b/core/server/scheduling/post-scheduling/index.js index bd19a7b112..16ef8ac288 100644 --- a/core/server/scheduling/post-scheduling/index.js +++ b/core/server/scheduling/post-scheduling/index.js @@ -13,11 +13,11 @@ _private.normalize = function normalize(options) { client = options.client; return { - time: object.get('published_at'), + time: moment(object.get('published_at')).valueOf(), url: apiUrl + '/schedules/posts/' + object.get('id') + '?client_id=' + client.get('slug') + '&client_secret=' + client.get('secret'), extra: { httpMethod: 'PUT', - oldTime: object.updated('published_at') || null + oldTime: object.updated('published_at') ? moment(object.updated('published_at')).valueOf() : null } }; }; diff --git a/core/test/integration/api/api_schedules_spec.js b/core/test/integration/api/api_schedules_spec.js index 55fd65bb18..c4ead313d4 100644 --- a/core/test/integration/api/api_schedules_spec.js +++ b/core/test/integration/api/api_schedules_spec.js @@ -231,10 +231,9 @@ describe('Schedules API', function () { slug: 'fourth' })); - Promise.all(scope.posts.map(function (post) { + Promise.mapSeries(scope.posts, function (post) { return models.Post.add(post, {context: {internal: true}}); - })).then(function (result) { - // returns id 1 and 2, but hard to check, because PG returns a different order + }).then(function (result) { result.length.should.eql(4); return done(); }).catch(done); diff --git a/core/test/unit/scheduling/post-scheduling/index_spec.js b/core/test/unit/scheduling/post-scheduling/index_spec.js index 79ecf92f4f..bb7390fc85 100644 --- a/core/test/unit/scheduling/post-scheduling/index_spec.js +++ b/core/test/unit/scheduling/post-scheduling/index_spec.js @@ -3,6 +3,7 @@ var should = require('should'), sinon = require('sinon'), Promise = require('bluebird'), + moment = require('moment'), config = require(__dirname + '/../../../../server/config'), testUtils = require(config.paths.corePath + '/test/utils'), errors = require(config.paths.corePath + '/server/errors'), @@ -71,7 +72,7 @@ describe('Scheduling: Post Scheduling', function () { scope.adapter.schedule.called.should.eql(true); scope.adapter.schedule.calledWith({ - time: scope.post.get('published_at'), + time: moment(scope.post.get('published_at')).valueOf(), url: scope.apiUrl + '/schedules/posts/' + scope.post.get('id') + '?client_id=' + scope.client.get('slug') + '&client_secret=' + scope.client.get('secret'), extra: { httpMethod: 'PUT',