mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-07 19:11:34 +02:00
Merge pull request #720 from vaucouleur/getErrorMessage
Article middleware was calling getErrorMessage with a null argument
This commit is contained in:
@@ -100,7 +100,7 @@ exports.articleByID = function(req, res, next, id) {
|
||||
if (err) return next(err);
|
||||
if (!article) {
|
||||
return res.status(404).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
message: 'No article with that identifier has been found'
|
||||
});
|
||||
}
|
||||
req.article = article;
|
||||
|
||||
@@ -223,7 +223,8 @@ describe('Article CRUD tests', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return proper error for single article which doesnt exist, if not signed in', function (done) {
|
||||
it('should return proper error for single article with an invalid Id, if not signed in', function (done) {
|
||||
// test is not a valid mongoose Id
|
||||
request(app).get('/api/articles/test')
|
||||
.end(function (req, res) {
|
||||
// Set assertion
|
||||
@@ -234,6 +235,18 @@ describe('Article CRUD tests', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return proper error for single article which doesnt exist, if not signed in', function (done) {
|
||||
// This is a valid mongoose Id but a non-existent article
|
||||
request(app).get('/api/articles/559e9cd815f80b4c256a8f41')
|
||||
.end(function (req, res) {
|
||||
// Set assertion
|
||||
res.body.should.be.instanceof(Object).and.have.property('message', 'No article with that identifier has been found');
|
||||
|
||||
// Call the assertion callback
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to delete an article if signed in', function (done) {
|
||||
agent.post('/api/auth/signin')
|
||||
.send(credentials)
|
||||
|
||||
Reference in New Issue
Block a user