mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Merge pull request #5612 from cobbspur/fixFeaturedPost
Fix API query for featured posts
This commit is contained in:
commit
d045cad0e5
3 changed files with 22 additions and 2 deletions
|
@ -314,7 +314,7 @@ Post = ghostBookshelf.Model.extend({
|
||||||
options.where.page = options.staticPages;
|
options.where.page = options.staticPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.featured) {
|
if (_.has(options, 'featured')) {
|
||||||
// convert string true/false to boolean
|
// convert string true/false to boolean
|
||||||
if (!_.isBoolean(options.featured)) {
|
if (!_.isBoolean(options.featured)) {
|
||||||
options.featured = _.contains(['true', '1'], options.featured);
|
options.featured = _.contains(['true', '1'], options.featured);
|
||||||
|
|
|
@ -19,6 +19,25 @@ describe('Post API', function () {
|
||||||
|
|
||||||
should.exist(PostAPI);
|
should.exist(PostAPI);
|
||||||
|
|
||||||
|
it('browse can fetch featured posts', function (done) {
|
||||||
|
PostAPI.browse({context: {user: 1}, featured: true}).then(function (results) {
|
||||||
|
should.exist(results.posts);
|
||||||
|
results.posts.length.should.eql(4);
|
||||||
|
results.posts[0].featured.should.eql(true);
|
||||||
|
|
||||||
|
done();
|
||||||
|
}).catch(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('browse can exclude featured posts', function (done) {
|
||||||
|
PostAPI.browse({context: {user: 1}, status: 'all', featured: false}).then(function (results) {
|
||||||
|
should.exist(results.posts);
|
||||||
|
results.posts.length.should.eql(1);
|
||||||
|
|
||||||
|
done();
|
||||||
|
}).catch(done);
|
||||||
|
});
|
||||||
|
|
||||||
it('can browse', function (done) {
|
it('can browse', function (done) {
|
||||||
PostAPI.browse().then(function (results) {
|
PostAPI.browse().then(function (results) {
|
||||||
should.exist(results);
|
should.exist(results);
|
||||||
|
|
|
@ -33,7 +33,8 @@ DataGenerator.Content = {
|
||||||
slug: "unfinished",
|
slug: "unfinished",
|
||||||
markdown: "<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant morbi tristique</strong> 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. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href=\"#\">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>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.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul><pre><code>#header h1 a{display: block;width: 300px;height: 80px;}</code></pre>",
|
markdown: "<h1>HTML Ipsum Presents</h1><p><strong>Pellentesque habitant morbi tristique</strong> 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. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href=\"#\">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p><h2>Header Level 2</h2><ol><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ol><blockquote><p>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.</p></blockquote><h3>Header Level 3</h3><ul><li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li><li>Aliquam tincidunt mauris eu risus.</li></ul><pre><code>#header h1 a{display: block;width: 300px;height: 80px;}</code></pre>",
|
||||||
status: "draft",
|
status: "draft",
|
||||||
uuid: "d52c42ae-2755-455c-80ec-70b2ec55c903"
|
uuid: "d52c42ae-2755-455c-80ec-70b2ec55c903",
|
||||||
|
featured: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Not so short, bit complex",
|
title: "Not so short, bit complex",
|
||||||
|
|
Loading…
Add table
Reference in a new issue