mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 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:
parent
eec5896d34
commit
57f8367cdf
1 changed files with 11 additions and 1 deletions
|
@ -1,7 +1,8 @@
|
||||||
var Promise = require('bluebird'),
|
var Promise = require('bluebird'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
fixtures = require('../../schema/fixtures'),
|
fixtures = require('../../schema/fixtures'),
|
||||||
logging = require('../../../logging');
|
logging = require('../../../logging'),
|
||||||
|
moment = require('moment');
|
||||||
|
|
||||||
module.exports = function insertFixtures(options) {
|
module.exports = function insertFixtures(options) {
|
||||||
var localOptions = _.merge({
|
var localOptions = _.merge({
|
||||||
|
@ -10,6 +11,15 @@ module.exports = function insertFixtures(options) {
|
||||||
|
|
||||||
return Promise.mapSeries(fixtures.models, function (model) {
|
return Promise.mapSeries(fixtures.models, function (model) {
|
||||||
logging.info('Model: ' + model.name);
|
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);
|
return fixtures.utils.addFixturesForModel(model, localOptions);
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
return Promise.mapSeries(fixtures.relations, function (relation) {
|
return Promise.mapSeries(fixtures.relations, function (relation) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue