0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Merge pull request #6374 from jtwebman/admin_error_no_theme

Fixed ghost admin error when missing theme folder.
This commit is contained in:
Hannah Wolfe 2016-01-25 12:29:31 +00:00
commit 4e355ecba9
2 changed files with 28 additions and 4 deletions

View file

@ -11,10 +11,14 @@ function isBlackListedFileType(file) {
} }
function forwardToExpressStatic(req, res, next) { function forwardToExpressStatic(req, res, next) {
express.static( if (!req.app.get('activeTheme')) {
path.join(config.paths.themePath, req.app.get('activeTheme')), next();
{maxAge: utils.ONE_YEAR_MS} } else {
)(req, res, next); express.static(
path.join(config.paths.themePath, req.app.get('activeTheme')),
{maxAge: utils.ONE_YEAR_MS}
)(req, res, next);
}
} }
function staticTheme() { function staticTheme() {

View file

@ -65,4 +65,24 @@ describe('staticTheme', function () {
done(); done();
}); });
}); });
it('should not error if active theme is missing', function (done) {
var req = {
url: 'myvalidfile.css',
app: {
get: function () { return undefined; }
}
},
activeThemeStub,
sandbox = sinon.sandbox.create();
activeThemeStub = sandbox.spy(req.app, 'get');
staticTheme(null)(req, null, function (reqArg, res, next2) {
/*jshint unused:false */
sandbox.restore();
next.called.should.be.false;
done();
});
});
}); });