mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Fix wrong error message
closes #1466 - added status code for error object - added test for frontend errors
This commit is contained in:
parent
5c90ef286c
commit
fd60a12469
@ -59,7 +59,9 @@ frontendControllers = {
|
||||
res.render('index', {posts: posts, pagination: {page: page.page, prev: page.prev, next: page.next, limit: page.limit, total: page.total, pages: page.pages}});
|
||||
});
|
||||
}).otherwise(function (err) {
|
||||
return next(new Error(err));
|
||||
var e = new Error(err.message);
|
||||
e.status = err.errorCode;
|
||||
return next(e);
|
||||
});
|
||||
},
|
||||
'single': function (req, res, next) {
|
||||
@ -78,7 +80,9 @@ frontendControllers = {
|
||||
}
|
||||
|
||||
}).otherwise(function (err) {
|
||||
return next(new Error(err));
|
||||
var e = new Error(err.message);
|
||||
e.status = err.errorCode;
|
||||
return next(e);
|
||||
});
|
||||
},
|
||||
'rss': function (req, res, next) {
|
||||
@ -151,7 +155,9 @@ frontendControllers = {
|
||||
});
|
||||
});
|
||||
}).otherwise(function (err) {
|
||||
return next(new Error(err));
|
||||
var e = new Error(err.message);
|
||||
e.status = err.errorCode;
|
||||
return next(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -196,7 +196,7 @@ errors = {
|
||||
if (!err || !(err instanceof Error)) {
|
||||
next();
|
||||
}
|
||||
errors.renderErrorPage(500, err, req, res, next);
|
||||
errors.renderErrorPage(err.status || 500, err, req, res, next);
|
||||
} else {
|
||||
res.send(err.status || 500, err);
|
||||
}
|
||||
|
17
core/test/functional/frontend/error_test.js
Normal file
17
core/test/functional/frontend/error_test.js
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Tests if RSS exists and is working
|
||||
*/
|
||||
/*globals CasperTest, casper */
|
||||
CasperTest.begin('Check post not found (404)', 2, function suite(test) {
|
||||
casper.thenOpen(url + 'asdf/', function (response) {
|
||||
test.assertEqual(response.status, 404, 'Response status should be 404.');
|
||||
test.assertSelectorHasText('.error-code', '404');
|
||||
});
|
||||
});
|
||||
|
||||
CasperTest.begin('Check frontend route not found (404)', 2, function suite(test) {
|
||||
casper.thenOpen(url + 'asdf/asdf/', function (response) {
|
||||
test.assertEqual(response.status, 404, 'Response status should be 404.');
|
||||
test.assertSelectorHasText('.error-code', '404');
|
||||
});
|
||||
});
|
@ -1,10 +1,11 @@
|
||||
/**
|
||||
* Tests if RSS exists and is working
|
||||
*/
|
||||
/*globals CasperTest, casper */
|
||||
CasperTest.begin('Ensure that RSS is available', 3, function suite(test) {
|
||||
casper.thenOpen(url + 'rss/', function (response) {
|
||||
test.assertEqual(response.status, 200, 'Response status should be 200.');
|
||||
test.assert(this.getPageContent().indexOf('<rss') >= 0, 'Feed should contain <rss');
|
||||
test.assert(this.getPageContent().indexOf('</rss>') >= 0, 'Feed should contain </rss>');
|
||||
});
|
||||
}, true);
|
||||
});
|
Loading…
Reference in New Issue
Block a user