🐛 Add `published_at` to post model fixtures (#8573)

closes #8562
- before we create our model fixtures, we assign a `published_at` property with a difference of 1 second for each blog post, so the `prev_post` and `next_post` helpers work correctly
This commit is contained in:
Aileen Nowak 2017-06-13 16:27:42 +07:00 committed by Kevin Ansfield
parent eec5896d34
commit 57f8367cdf
1 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,8 @@
var Promise = require('bluebird'),
_ = require('lodash'),
fixtures = require('../../schema/fixtures'),
logging = require('../../../logging');
logging = require('../../../logging'),
moment = require('moment');
module.exports = function insertFixtures(options) {
var localOptions = _.merge({
@ -10,6 +11,15 @@ module.exports = function insertFixtures(options) {
return Promise.mapSeries(fixtures.models, function (model) {
logging.info('Model: ' + model.name);
// The Post model fixtures need a `published_at` date, where at least the seconds
// are different, otherwise `prev_post` and `next_post` helpers won't workd with
// them.
if (model.name === 'Post') {
_.forEach(model.entries, function (post, index) {
post.published_at = moment().add(index, 'seconds');
});
}
return fixtures.utils.addFixturesForModel(model, localOptions);
}).then(function () {
return Promise.mapSeries(fixtures.relations, function (relation) {