Merge pull request #1240 from strongloop/replaceById-test

Ensure replaceById returns 404 when id not found
This commit is contained in:
Loay 2017-02-01 13:11:26 -05:00 committed by GitHub
commit ad9934159b
1 changed files with 21 additions and 0 deletions

View File

@ -1340,6 +1340,27 @@ describe('manipulation', function() {
});
}
hasReplaceById = !!getSchema().connector.replaceById;
bdd.describeIf(hasReplaceById, 'replaceById', function() {
var Post;
before(function(done) {
var ds = getSchema();
Post = ds.define('Post', {
title: {type: String, length: 255},
content: {type: String},
}, {forceId: true});
ds.automigrate('Post', done);
});
it('fails when id does not exist in db using replaceById', function(done) {
var post = {id: 123, title: 'a', content: 'AAA'};
Post.replaceById(post.id, post, function(err, p) {
err.statusCode.should.equal(404);
done();
});
});
});
describe('findOrCreate', function() {
it('should create a record with if new', function(done) {
Person.findOrCreate({name: 'Zed', gender: 'male'},