Merge pull request #7017 from kirrg001/fix/prev-next-post

fix: prev next posts
This commit is contained in:
Austin Burdine 2016-06-21 06:57:48 -04:00 committed by GitHub
commit dc0416bbe8
2 changed files with 30 additions and 4 deletions

View File

@ -551,7 +551,7 @@ Post = ghostBookshelf.Model.extend({
return ghostBookshelf.Model.findOne.call(this, data, options).then(function then(post) {
if ((withNext || withPrev) && post && !post.page) {
var publishedAt = post.get('published_at'),
var publishedAt = moment(post.get('published_at')).format('YYYY-MM-DD HH:mm:ss'),
prev,
next;

View File

@ -1,14 +1,40 @@
var testUtils = require('../../utils'),
var Promise = require('bluebird'),
should = require('should'),
_ = require('lodash'),
testUtils = require('../../utils'),
errors = require('../../../server/errors'),
db = require('../../../server/data/db'),
models = require('../../../server/models'),
PostAPI = require('../../../server/api/posts');
describe('Post API', function () {
// Keep the DB clean
before(testUtils.teardown);
afterEach(testUtils.teardown);
beforeEach(testUtils.setup('users:roles', 'perms:post', 'posts', 'perms:init'));
beforeEach(testUtils.setup('users:roles', 'perms:post', 'perms:init'));
// @TODO: remove when https://github.com/TryGhost/Ghost/issues/6930 is fixed
// we insert the posts via the model layer, because right now the test utils insert dates wrong
beforeEach(function (done) {
Promise.mapSeries(testUtils.DataGenerator.forKnex.posts, function (post) {
return models.Post.add(post, {context: {internal:true}});
}).then(function () {
done();
}).catch(done);
});
beforeEach(function (done) {
Promise.mapSeries(testUtils.DataGenerator.forKnex.tags, function (tag) {
return models.Tag.add(tag, {context: {internal:true}});
}).then(function () {
done();
}).catch(done);
});
beforeEach(function (done) {
db.knex('posts_tags').insert(testUtils.DataGenerator.forKnex.posts_tags)
.then(function () {
done();
})
.catch(done);
});
function extractFirstPost(posts) {
return _.filter(posts, {id: 1})[0];