mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Fix API query for featured posts
No Issue - fixes bug where featured: false was not being built into query - adds tests
This commit is contained in:
parent
14c35ea56c
commit
870d6af066
3 changed files with 22 additions and 2 deletions
|
@ -314,7 +314,7 @@ Post = ghostBookshelf.Model.extend({
|
|||
options.where.page = options.staticPages;
|
||||
}
|
||||
|
||||
if (options.featured) {
|
||||
if (_.has(options, 'featured')) {
|
||||
// convert string true/false to boolean
|
||||
if (!_.isBoolean(options.featured)) {
|
||||
options.featured = _.contains(['true', '1'], options.featured);
|
||||
|
|
|
@ -19,6 +19,25 @@ describe('Post API', function () {
|
|||
|
||||
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) {
|
||||
PostAPI.browse().then(function (results) {
|
||||
should.exist(results);
|
||||
|
|
|
@ -33,7 +33,8 @@ DataGenerator.Content = {
|
|||
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>",
|
||||
status: "draft",
|
||||
uuid: "d52c42ae-2755-455c-80ec-70b2ec55c903"
|
||||
uuid: "d52c42ae-2755-455c-80ec-70b2ec55c903",
|
||||
featured: false
|
||||
},
|
||||
{
|
||||
title: "Not so short, bit complex",
|
||||
|
|
Loading…
Reference in a new issue