mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Ensure {{get}} helper returns pagination
No Issue - pagination returned if meta pagination exists - needed to allow pagination helper to work
This commit is contained in:
parent
cc3b9e9f53
commit
0ce4078f45
2 changed files with 32 additions and 3 deletions
|
@ -124,9 +124,10 @@ get = function get(context, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// block params allows the theme developer to name the data using something like
|
// block params allows the theme developer to name the data using something like
|
||||||
// `{{#get "posts" as |result pagination|}}`
|
// `{{#get "posts" as |result pageInfo|}}`
|
||||||
blockParams = [result[context]];
|
blockParams = [result[context]];
|
||||||
if (result.meta && result.meta.pagination) {
|
if (result.meta && result.meta.pagination) {
|
||||||
|
result.pagination = result.meta.pagination;
|
||||||
blockParams.push(result.meta.pagination);
|
blockParams.push(result.meta.pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ describe('{{#get}} helper', function () {
|
||||||
readTagsStub = sandbox.stub(api.tags, 'read').returns(new Promise.resolve({tags: []}));
|
readTagsStub = sandbox.stub(api.tags, 'read').returns(new Promise.resolve({tags: []}));
|
||||||
readUsersStub = sandbox.stub(api.users, 'read').returns(new Promise.resolve({users: []}));
|
readUsersStub = sandbox.stub(api.users, 'read').returns(new Promise.resolve({users: []}));
|
||||||
|
|
||||||
browsePostsStub.returns(new Promise.resolve({posts: testPostsArr}));
|
browsePostsStub.returns(new Promise.resolve({posts: testPostsArr, meta: meta}));
|
||||||
browsePostsStub.withArgs({limit: '3'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 3), meta: meta}));
|
browsePostsStub.withArgs({limit: '3'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 3), meta: meta}));
|
||||||
browsePostsStub.withArgs({limit: '1'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 1)}));
|
browsePostsStub.withArgs({limit: '1'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 1)}));
|
||||||
browsePostsStub.withArgs({filter: 'tags:test'}).returns(new Promise.resolve({posts: testPostsArr.slice(2, 3)}));
|
browsePostsStub.withArgs({filter: 'tags:test'}).returns(new Promise.resolve({posts: testPostsArr.slice(2, 3)}));
|
||||||
|
@ -76,6 +76,35 @@ describe('{{#get}} helper', function () {
|
||||||
}).catch(done);
|
}).catch(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return pagination and meta pagination with default browse posts call', function (done) {
|
||||||
|
helpers.get.call(
|
||||||
|
{},
|
||||||
|
'posts',
|
||||||
|
{hash: {}, fn: fn, inverse: inverse}
|
||||||
|
).then(function () {
|
||||||
|
fn.firstCall.args[0].pagination.should.be.an.Object;
|
||||||
|
fn.firstCall.args[0].meta.should.be.an.Object;
|
||||||
|
fn.firstCall.args[0].meta.pagination.should.be.an.Object;
|
||||||
|
inverse.called.should.be.false;
|
||||||
|
|
||||||
|
done();
|
||||||
|
}).catch(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not return pagination if meta pagination does not exist', function (done) {
|
||||||
|
helpers.get.call(
|
||||||
|
{},
|
||||||
|
'posts',
|
||||||
|
{hash: {limit: '1'}, fn: fn, inverse: inverse}
|
||||||
|
).then(function () {
|
||||||
|
should.not.exist(fn.firstCall.args[0].pagination);
|
||||||
|
should.not.exist(fn.firstCall.args[0].meta);
|
||||||
|
inverse.called.should.be.false;
|
||||||
|
|
||||||
|
done();
|
||||||
|
}).catch(done);
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle browse posts call with limit 3', function (done) {
|
it('should handle browse posts call with limit 3', function (done) {
|
||||||
helpers.get.call(
|
helpers.get.call(
|
||||||
{},
|
{},
|
||||||
|
@ -331,4 +360,3 @@ describe('{{#get}} helper', function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue