mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Merge pull request #1489 from sebgie/issue#1466
Fix wrong error message
This commit is contained in:
commit
315ca052a9
4 changed files with 29 additions and 5 deletions
|
@ -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}});
|
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) {
|
}).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) {
|
'single': function (req, res, next) {
|
||||||
|
@ -78,7 +80,9 @@ frontendControllers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
}).otherwise(function (err) {
|
}).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) {
|
'rss': function (req, res, next) {
|
||||||
|
@ -151,7 +155,9 @@ frontendControllers = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).otherwise(function (err) {
|
}).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)) {
|
if (!err || !(err instanceof Error)) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
errors.renderErrorPage(500, err, req, res, next);
|
errors.renderErrorPage(err.status || 500, err, req, res, next);
|
||||||
} else {
|
} else {
|
||||||
res.send(err.status || 500, err);
|
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
|
* Tests if RSS exists and is working
|
||||||
*/
|
*/
|
||||||
|
/*globals CasperTest, casper */
|
||||||
CasperTest.begin('Ensure that RSS is available', 3, function suite(test) {
|
CasperTest.begin('Ensure that RSS is available', 3, function suite(test) {
|
||||||
casper.thenOpen(url + 'rss/', function (response) {
|
casper.thenOpen(url + 'rss/', function (response) {
|
||||||
test.assertEqual(response.status, 200, 'Response status should be 200.');
|
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');
|
||||||
test.assert(this.getPageContent().indexOf('</rss>') >= 0, 'Feed should contain </rss>');
|
test.assert(this.getPageContent().indexOf('</rss>') >= 0, 'Feed should contain </rss>');
|
||||||
});
|
});
|
||||||
}, true);
|
});
|
Loading…
Add table
Reference in a new issue