0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Minor fixes to asset helper and tests

no issue

- asset helper ignores it if theme devs specify the asset dir
- asset helper strips leading slashes
- static asset tests were wrong
This commit is contained in:
Hannah Wolfe 2014-01-12 21:48:34 +00:00
parent 595b326b36
commit 9f0dea0559
2 changed files with 10 additions and 5 deletions

View file

@ -115,7 +115,7 @@ coreHelpers.asset = function (context, options) {
output += config.paths().subdir + '/';
if (!context.match(/^favicon\.ico$/) && !context.match(/^shared/)) {
if (!context.match(/^favicon\.ico$/) && !context.match(/^shared/) && !context.match(/^asset/)) {
if (isAdmin) {
output += 'ghost/';
} else {
@ -123,6 +123,8 @@ coreHelpers.asset = function (context, options) {
}
}
// Get rid of any leading slash on the context
context = context.replace(/^\//, '');
output += context;
if (!context.match(/^favicon\.ico$/)) {

View file

@ -262,26 +262,29 @@ describe('Frontend Routing', function () {
describe('Static assets', function () {
it('should retrieve shared assets', function (done) {
request.get('/shared/img/usr-image.png')
.expect('Cache-Control', cacheRules.year)
request.get('/shared/img/user-image.png')
.expect('Cache-Control', cacheRules.hour)
.expect(200)
.end(doEnd(done));
});
it('should retrieve theme assets', function (done) {
request.get('/assets/css/screen.css')
.expect('Cache-Control', cacheRules.hour)
.expect(200)
.end(doEnd(done));
});
it('should retrieve built assets', function (done) {
request.get('/ghost/built/vendor.js')
request.get('/ghost/scripts/vendor.js')
.expect('Cache-Control', cacheRules.year)
.expect(200)
.end(doEnd(done));
});
// at the moment there is no image fixture to test
// it('should retrieve image assets', function (done) {
// request.get('/assets/css/screen.css')
// request.get('/content/images/some.jpg')
// .expect('Cache-Control', cacheRules.year)
// .end(doEnd(done));
// });