mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 16:14:25 +03:00
Merge pull request #7017 from kirrg001/fix/prev-next-post
fix: prev next posts
This commit is contained in:
commit
dc0416bbe8
@ -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;
|
||||
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user