mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -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:
commit
4e355ecba9
2 changed files with 28 additions and 4 deletions
|
@ -11,10 +11,14 @@ function isBlackListedFileType(file) {
|
|||
}
|
||||
|
||||
function forwardToExpressStatic(req, res, next) {
|
||||
express.static(
|
||||
path.join(config.paths.themePath, req.app.get('activeTheme')),
|
||||
{maxAge: utils.ONE_YEAR_MS}
|
||||
)(req, res, next);
|
||||
if (!req.app.get('activeTheme')) {
|
||||
next();
|
||||
} else {
|
||||
express.static(
|
||||
path.join(config.paths.themePath, req.app.get('activeTheme')),
|
||||
{maxAge: utils.ONE_YEAR_MS}
|
||||
)(req, res, next);
|
||||
}
|
||||
}
|
||||
|
||||
function staticTheme() {
|
||||
|
|
|
@ -65,4 +65,24 @@ describe('staticTheme', function () {
|
|||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue