Merge pull request #959 from strongloop/fix_err_msg

Fix error message
This commit is contained in:
Amir-61 2016-06-01 21:00:26 -04:00
commit 7aa9cb357d
2 changed files with 13 additions and 1 deletions

View File

@ -2648,7 +2648,7 @@ DataAccessObject.replaceById = function(id, data, options, cb) {
if (id !== data[pkName]) {
var err = new Error('id property (' + pkName + ') ' +
'cannot be updated from ' + inst[pkName] + ' to ' + data[pkName]);
'cannot be updated from ' + id + ' to ' + data[pkName]);
err.statusCode = 400;
process.nextTick(function() { cb(err); });
return cb.promise;

View File

@ -1020,6 +1020,18 @@ describe('manipulation', function() {
.catch(done);
});
it('should fail when changing id', function(done) {
Post.findById(postInstance.id, function(err, p) {
if (err) return done(err);
p.replaceAttributes({ title: 'b', id: 999 }, function(err, p) {
should.exist(err);
var expectedErrMsg = 'id property (id) cannot be updated from ' + postInstance.id + ' to 999';
err.message.should.equal(expectedErrMsg);
done();
});
});
});
it('works without options(callback variant)', function(done) {
Post.findById(postInstance.id, function(err, p) {
if (err) return done(err);