0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Merge pull request #3559 from jaswilli/post-api-tests

Fix failure in Post API tests.
This commit is contained in:
Sebastian Gierlinger 2014-08-01 20:23:52 +02:00
commit 51e64e7beb

View file

@ -2,6 +2,7 @@
/*jshint expr:true*/ /*jshint expr:true*/
var testUtils = require('../../utils'), var testUtils = require('../../utils'),
should = require('should'), should = require('should'),
_ = require('lodash'),
// Stuff we are testing // Stuff we are testing
PostAPI = require('../../../server/api/posts'); PostAPI = require('../../../server/api/posts');
@ -13,6 +14,9 @@ describe('Post API', function () {
afterEach(testUtils.teardown); afterEach(testUtils.teardown);
beforeEach(testUtils.setup('users:roles', 'perms:post', 'posts', 'perms:init')); beforeEach(testUtils.setup('users:roles', 'perms:post', 'posts', 'perms:init'));
function extractFirstPost(posts) {
return _.filter(posts, { id: 1 })[0];
}
should.exist(PostAPI); should.exist(PostAPI);
@ -34,7 +38,7 @@ describe('Post API', function () {
should.exist(results); should.exist(results);
should.exist(results.posts); should.exist(results.posts);
results.posts.length.should.be.above(0); results.posts.length.should.be.above(0);
firstPost = results.posts[0]; firstPost = extractFirstPost(results.posts);
return PostAPI.read({slug: firstPost.slug, include: 'tags'}); return PostAPI.read({slug: firstPost.slug, include: 'tags'});
}).then(function (found) { }).then(function (found) {
var post; var post;