Merge pull request #4290 from sujeshthekkepatt/fix/hasone-relation-error-message

feat: change hasone relation error message
This commit is contained in:
Diana Lau 2019-12-15 19:32:43 -05:00 committed by GitHub
commit 6a7fc529fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -565,7 +565,9 @@ module.exports = function(registry) {
if (ctx.result !== null) return cb();
const fk = ctx.getArgByName('fk');
const msg = g.f('Unknown "%s" id "%s".', toModelName, fk);
const msg = fk ?
g.f('Unknown "%s" id "%s".', toModelName, fk) :
g.f('No "%s" instance(s) found', toModelName);
const error = new Error(msg);
error.statusCode = error.status = 404;
error.code = 'MODEL_NOT_FOUND';

View File

@ -1810,6 +1810,11 @@ describe('relations - integration', function() {
const url = '/api/customers/' + cust.id + '/profile';
this.get(url)
.expect(404, function(err, res) {
const expected = 'No "profile" instance(s) found';
expect(res.body.error.message).to.be.equal(
expected,
);
expect(res.body.error.code).to.be.equal('MODEL_NOT_FOUND');
done(err);
});
});