diff --git a/core/server/data/meta/rss_url.js b/core/server/data/meta/rss_url.js index fe4c7c3fd0..4fa6731cd9 100644 --- a/core/server/data/meta/rss_url.js +++ b/core/server/data/meta/rss_url.js @@ -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; diff --git a/core/test/integration/web/site_spec.js b/core/test/integration/web/site_spec.js index 9d4ef237b5..0f5d78b1cb 100644 --- a/core/test/integration/web/site_spec.js +++ b/core/test/integration/web/site_spec.js @@ -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 () {