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

  1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  2. 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

#header h1 a{display: block;width: 300px;height: 80px;}
'), status: 'draft', - uuid: 'd52c42ae-2755-455c-80ec-70b2ec55c903', - featured: false + uuid: 'd52c42ae-2755-455c-80ec-70b2ec55c903' }, { id: ObjectId.generate(), title: 'Not so short, bit complex', slug: 'not-so-short-bit-complex', - mobiledoc: DataGenerator.markdownToMobiledoc('

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.

1234
abcd
efgh
ijkl
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.

') + mobiledoc: DataGenerator.markdownToMobiledoc('

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.

1234
abcd
efgh
ijkl
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.

'), + featured: true }, { id: ObjectId.generate(), @@ -431,7 +432,7 @@ DataGenerator.forKnex = (function () { uuid: uuid.v4(), title: 'title', status: 'published', - featured: true, + featured: false, page: false, author_id: DataGenerator.Content.users[0].id, updated_at: new Date(),