From 61be92e3f9bb5f0ed840efb2691e69b0b64e1a85 Mon Sep 17 00:00:00 2001
From: kirrg001
Date: Sat, 14 Apr 2018 10:32:03 +0200
Subject: [PATCH] Tests: balance featured and none featured posts
no issue
- `featured:true` was default
- featured is by default disabled in Ghost
- balance featured and none featured posts
- update tests
---
core/test/functional/routes/api/posts_spec.js | 2 +-
core/test/integration/api/api_posts_spec.js | 6 +++---
core/test/integration/model/model_posts_spec.js | 8 ++++----
core/test/utils/fixtures/data-generator.js | 11 ++++++-----
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/core/test/functional/routes/api/posts_spec.js b/core/test/functional/routes/api/posts_spec.js
index 9b603ad8c6..17e5e6d793 100644
--- a/core/test/functional/routes/api/posts_spec.js
+++ b/core/test/functional/routes/api/posts_spec.js
@@ -269,7 +269,7 @@ describe('Post API', function () {
var jsonResponse = res.body;
should.exist(jsonResponse.posts);
testUtils.API.checkResponse(jsonResponse, 'posts');
- jsonResponse.posts.should.have.length(4);
+ jsonResponse.posts.should.have.length(2);
testUtils.API.checkResponse(jsonResponse.posts[0], 'post');
testUtils.API.checkResponse(jsonResponse.meta.pagination, 'pagination');
done();
diff --git a/core/test/integration/api/api_posts_spec.js b/core/test/integration/api/api_posts_spec.js
index e8ccfcb701..b124327034 100644
--- a/core/test/integration/api/api_posts_spec.js
+++ b/core/test/integration/api/api_posts_spec.js
@@ -99,7 +99,7 @@ describe('Post API', function () {
it('can fetch featured posts for user 1', function (done) {
PostAPI.browse(_.merge({filter: 'featured:true'}, testUtils.context.owner)).then(function (results) {
should.exist(results.posts);
- results.posts.length.should.eql(4);
+ results.posts.length.should.eql(2);
results.posts[0].featured.should.eql(true);
done();
}).catch(done);
@@ -108,7 +108,7 @@ describe('Post API', function () {
it('can fetch featured posts for user 2', function (done) {
PostAPI.browse(_.merge({filter: 'featured:true'}, testUtils.context.admin)).then(function (results) {
should.exist(results.posts);
- results.posts.length.should.eql(4);
+ results.posts.length.should.eql(2);
results.posts[0].featured.should.eql(true);
done();
}).catch(done);
@@ -120,7 +120,7 @@ describe('Post API', function () {
filter: 'featured:false'
}, testUtils.context.owner)).then(function (results) {
should.exist(results.posts);
- results.posts.length.should.eql(1);
+ results.posts.length.should.eql(4);
results.posts[0].featured.should.eql(false);
done();
diff --git a/core/test/integration/model/model_posts_spec.js b/core/test/integration/model/model_posts_spec.js
index 37906fa841..88af0a05f8 100644
--- a/core/test/integration/model/model_posts_spec.js
+++ b/core/test/integration/model/model_posts_spec.js
@@ -261,16 +261,16 @@ describe('Post Model', function () {
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
- paginationResult.meta.pagination.pages.should.equal(6);
- paginationResult.posts.length.should.equal(10);
+ paginationResult.meta.pagination.pages.should.equal(1);
+ paginationResult.posts.length.should.equal(2);
// Test both boolean formats for featured pages
return models.Post.findPage({limit: 10, filter: 'featured:1'});
}).then(function (paginationResult) {
paginationResult.meta.pagination.page.should.equal(1);
paginationResult.meta.pagination.limit.should.equal(10);
- paginationResult.meta.pagination.pages.should.equal(6);
- paginationResult.posts.length.should.equal(10);
+ paginationResult.meta.pagination.pages.should.equal(1);
+ paginationResult.posts.length.should.equal(2);
return models.Post.findPage({limit: 10, page: 2, status: 'all'});
}).then(function (paginationResult) {
diff --git a/core/test/utils/fixtures/data-generator.js b/core/test/utils/fixtures/data-generator.js
index e60b60d88c..ba15b5d852 100644
--- a/core/test/utils/fixtures/data-generator.js
+++ b/core/test/utils/fixtures/data-generator.js
@@ -52,7 +52,8 @@ DataGenerator.Content = {
feature_image: 'http://placekitten.com/500/200',
meta_description: 'test stuff',
published_at: new Date('2015-01-03'),
- uuid: '2ac6b4f6-e1f3-406c-9247-c94a0496d39d'
+ uuid: '2ac6b4f6-e1f3-406c-9247-c94a0496d39d',
+ featured: true
},
{
id: ObjectId.generate(),
@@ -60,14 +61,14 @@ DataGenerator.Content = {
slug: 'unfinished',
mobiledoc: DataGenerator.markdownToMobiledoc('
HTML Ipsum Presents
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.
Header Level 2
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam tincidunt mauris eu risus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
Header Level 3
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
1
2
3
4
a
b
c
d
e
f
g
h
i
j
k
l
Definition list
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.
Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.
Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.
Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
1
2
3
4
a
b
c
d
e
f
g
h
i
j
k
l
Definition list
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Lorem ipsum dolor sit amet
Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Morbi in sem quis dui placerat ornare. Pellentesque odio nisi, euismod in, pharetra a, ultricies in, diam. Sed arcu. Cras consequat.
Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus.
Phasellus ultrices nulla quis nibh. Quisque a lectus. Donec consectetuer ligula vulputate sem tristique cursus. Nam nulla quam, gravida non, commodo a, sodales sit amet, nisi.
Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.