mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Fixing undefined page case for page_url helper
closes #6719 - covers the case that no page should be the same as page 1
This commit is contained in:
parent
8b53308f10
commit
352f4eb2fc
@ -15,6 +15,10 @@ var errors = require('../errors'),
|
||||
pageUrl;
|
||||
|
||||
page_url = function (page, options) {
|
||||
if (!options) {
|
||||
options = page;
|
||||
page = 1;
|
||||
}
|
||||
return getPaginatedUrl(page, options.data.root);
|
||||
};
|
||||
|
||||
|
@ -45,6 +45,14 @@ describe('{{page_url}} helper', function () {
|
||||
helpers.page_url('next', options).should.eql('/tag/pumpkin/page/10/');
|
||||
helpers.page_url('prev', options).should.eql('/tag/pumpkin/page/2/');
|
||||
});
|
||||
|
||||
it('should assume 1 if page is undefined', function () {
|
||||
options.data.root.relativeUrl = '/tag/pumpkin/';
|
||||
options.data.root.pagination.next = 10;
|
||||
options.data.root.pagination.prev = 2;
|
||||
|
||||
helpers.page_url(options).should.equal(helpers.page_url(1, options));
|
||||
});
|
||||
});
|
||||
|
||||
describe('{{pageUrl}} helper [DEPRECATED]', function () {
|
||||
@ -63,6 +71,7 @@ describe('{{pageUrl}} helper [DEPRECATED]', function () {
|
||||
options.data.root.pagination.next = 5;
|
||||
options.data.root.pagination.prev = 7;
|
||||
|
||||
helpers.pageUrl(options).should.eql(helpers.page_url(options));
|
||||
helpers.pageUrl(1, options).should.eql(helpers.page_url(1, options));
|
||||
helpers.pageUrl(20, options).should.eql(helpers.page_url(20, options));
|
||||
helpers.pageUrl('next', options).should.eql(helpers.page_url('next', options));
|
||||
@ -74,6 +83,7 @@ describe('{{pageUrl}} helper [DEPRECATED]', function () {
|
||||
options.data.root.pagination.next = 12;
|
||||
options.data.root.pagination.prev = 9;
|
||||
|
||||
helpers.pageUrl(options).should.eql(helpers.page_url(options));
|
||||
helpers.pageUrl(1, options).should.eql(helpers.page_url(1, options));
|
||||
helpers.pageUrl(20, options).should.eql(helpers.page_url(20, options));
|
||||
helpers.pageUrl('next', options).should.eql(helpers.page_url('next', options));
|
||||
|
Loading…
Reference in New Issue
Block a user