mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 02:44:33 +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) {
|
return ghostBookshelf.Model.findOne.call(this, data, options).then(function then(post) {
|
||||||
if ((withNext || withPrev) && post && !post.page) {
|
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,
|
prev,
|
||||||
next;
|
next;
|
||||||
|
|
||||||
|
@ -1,14 +1,40 @@
|
|||||||
var testUtils = require('../../utils'),
|
var Promise = require('bluebird'),
|
||||||
should = require('should'),
|
should = require('should'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
|
testUtils = require('../../utils'),
|
||||||
errors = require('../../../server/errors'),
|
errors = require('../../../server/errors'),
|
||||||
|
db = require('../../../server/data/db'),
|
||||||
|
models = require('../../../server/models'),
|
||||||
PostAPI = require('../../../server/api/posts');
|
PostAPI = require('../../../server/api/posts');
|
||||||
|
|
||||||
describe('Post API', function () {
|
describe('Post API', function () {
|
||||||
// Keep the DB clean
|
|
||||||
before(testUtils.teardown);
|
before(testUtils.teardown);
|
||||||
afterEach(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) {
|
function extractFirstPost(posts) {
|
||||||
return _.filter(posts, {id: 1})[0];
|
return _.filter(posts, {id: 1})[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user