diff --git a/core/server/helpers/get.js b/core/server/helpers/get.js index 2787ca4490..59baea4668 100644 --- a/core/server/helpers/get.js +++ b/core/server/helpers/get.js @@ -124,9 +124,10 @@ get = function get(context, options) { } // 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]]; if (result.meta && result.meta.pagination) { + result.pagination = result.meta.pagination; blockParams.push(result.meta.pagination); } diff --git a/core/test/unit/server_helpers/get_spec.js b/core/test/unit/server_helpers/get_spec.js index 80eed22a79..7f8eb2e3a0 100644 --- a/core/test/unit/server_helpers/get_spec.js +++ b/core/test/unit/server_helpers/get_spec.js @@ -50,7 +50,7 @@ describe('{{#get}} helper', function () { readTagsStub = sandbox.stub(api.tags, 'read').returns(new Promise.resolve({tags: []})); 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: '1'}).returns(new Promise.resolve({posts: testPostsArr.slice(0, 1)})); browsePostsStub.withArgs({filter: 'tags:test'}).returns(new Promise.resolve({posts: testPostsArr.slice(2, 3)})); @@ -76,6 +76,35 @@ describe('{{#get}} helper', function () { }).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) { helpers.get.call( {}, @@ -331,4 +360,3 @@ describe('{{#get}} helper', function () { }); }); }); -