mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Protected error if routes.yaml file doesn't contain any collections
no issue - if you define no collections, but a static route, it can happen that the target template to render makes use of the {{ghost_head}} helper - the {{ghost_head}} helper tries to create the primary rss feed url - at the moment: no collections, no primary rss feed url - if we offer the option to define custom rss rules, this function might need an extension
This commit is contained in:
parent
835fd6c45b
commit
8a10826518
2 changed files with 98 additions and 46 deletions
|
@ -9,13 +9,16 @@ const routingService = require('../../services/routing');
|
|||
* @TODO: We are currently investigating this.
|
||||
*/
|
||||
function getRssUrl(data, absolute) {
|
||||
return routingService
|
||||
.registry
|
||||
.getFirstCollectionRouter()
|
||||
.getRssUrl({
|
||||
secure: data.secure,
|
||||
absolute: absolute
|
||||
});
|
||||
const firstCollection = routingService.registry.getFirstCollectionRouter();
|
||||
|
||||
if (!firstCollection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return firstCollection.getRssUrl({
|
||||
secure: data.secure,
|
||||
absolute: absolute
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = getRssUrl;
|
||||
|
|
|
@ -425,53 +425,53 @@ describe('Integration - Web - Site', function () {
|
|||
});
|
||||
|
||||
describe('extended routes.yaml (1): 2 collections', function () {
|
||||
before(function () {
|
||||
sandbox.stub(settingsService, 'get').returns({
|
||||
routes: {
|
||||
'/': 'home'
|
||||
},
|
||||
|
||||
collections: {
|
||||
'/podcast/': {
|
||||
permalink: '/podcast/:slug/',
|
||||
filter: 'featured:true'
|
||||
describe('behaviour: default cases', function () {
|
||||
before(function () {
|
||||
sandbox.stub(settingsService, 'get').returns({
|
||||
routes: {
|
||||
'/': 'home'
|
||||
},
|
||||
|
||||
'/something/': {
|
||||
permalink: '/something/:slug/'
|
||||
}
|
||||
},
|
||||
collections: {
|
||||
'/podcast/': {
|
||||
permalink: '/podcast/:slug/',
|
||||
filter: 'featured:true'
|
||||
},
|
||||
|
||||
taxonomies: {
|
||||
tag: '/categories/:slug/',
|
||||
author: '/authors/:slug/'
|
||||
}
|
||||
'/something/': {
|
||||
permalink: '/something/:slug/'
|
||||
}
|
||||
},
|
||||
|
||||
taxonomies: {
|
||||
tag: '/categories/:slug/',
|
||||
author: '/authors/:slug/'
|
||||
}
|
||||
});
|
||||
|
||||
testUtils.integrationTesting.urlService.resetGenerators();
|
||||
testUtils.integrationTesting.defaultMocks(sandbox);
|
||||
|
||||
return testUtils.integrationTesting.initGhost()
|
||||
.then(function () {
|
||||
app = siteApp();
|
||||
|
||||
return testUtils.integrationTesting.urlService.waitTillFinished();
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.integrationTesting.urlService.resetGenerators();
|
||||
testUtils.integrationTesting.defaultMocks(sandbox);
|
||||
beforeEach(function () {
|
||||
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
||||
});
|
||||
|
||||
return testUtils.integrationTesting.initGhost()
|
||||
.then(function () {
|
||||
app = siteApp();
|
||||
afterEach(function () {
|
||||
configUtils.restore();
|
||||
});
|
||||
|
||||
return testUtils.integrationTesting.urlService.waitTillFinished();
|
||||
});
|
||||
});
|
||||
after(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
configUtils.restore();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
describe('behaviour: default cases', function () {
|
||||
it('serve home', function () {
|
||||
const req = {
|
||||
secure: true,
|
||||
|
@ -556,6 +556,55 @@ describe('Integration - Web - Site', function () {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('no collections', function () {
|
||||
before(function () {
|
||||
sandbox.stub(settingsService, 'get').returns({
|
||||
routes: {
|
||||
'/test/': 'test'
|
||||
},
|
||||
collections: {},
|
||||
taxonomies: {}
|
||||
});
|
||||
|
||||
testUtils.integrationTesting.urlService.resetGenerators();
|
||||
testUtils.integrationTesting.defaultMocks(sandbox);
|
||||
|
||||
return testUtils.integrationTesting.initGhost()
|
||||
.then(function () {
|
||||
app = siteApp();
|
||||
|
||||
return testUtils.integrationTesting.urlService.waitTillFinished();
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
testUtils.integrationTesting.overrideGhostConfig(configUtils);
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
configUtils.restore();
|
||||
});
|
||||
|
||||
after(function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it('serve route', function () {
|
||||
const req = {
|
||||
secure: true,
|
||||
method: 'GET',
|
||||
url: '/test/',
|
||||
host: 'example.com'
|
||||
};
|
||||
|
||||
return testUtils.mocks.express.invoke(app, req)
|
||||
.then(function (response) {
|
||||
response.statusCode.should.eql(200);
|
||||
response.template.should.eql('index');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('extended routes.yaml (2): static permalink route', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue