diff --git a/lib/dao.js b/lib/dao.js index 86752951..d4b39986 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -543,7 +543,7 @@ DataAccessObject.upsert = function(data, options, cb) { const model = new Model({id: id}, {persisted: true}); model.updateAttributes(data, options, cb); } - return; + return cb.promise; } var context = { diff --git a/test/manipulation.test.js b/test/manipulation.test.js index 4f12776d..21784466 100644 --- a/test/manipulation.test.js +++ b/test/manipulation.test.js @@ -920,7 +920,7 @@ describe('manipulation', function() { var unknownId = uid.fromConnector(db) || 123; var post = {id: unknownId, title: 'a', content: 'AAA'}; Post.updateOrCreate(post, {validate: true}, (err) => { - err.statusCode.should.equal(404); + should(err).have.property('statusCode', 404); done(); }); }); @@ -929,20 +929,20 @@ describe('manipulation', function() { var unknownId = uid.fromConnector(db) || 123; var post = {id: unknownId, title: 'a', content: 'AAA'}; Post.updateOrCreate(post, {validate: false}, (err) => { - err.statusCode.should.equal(404); + should(err).have.property('statusCode', 404); done(); }); }); it('fails when id does not exist in db & validate is false when using updateAttributes', - function(done) { - var unknownId = uid.fromConnector(db) || 123; - var post = new Post({id: unknownId}); - post.updateAttributes({title: 'updated title', content: 'AAA'}, {validate: false}, (err) => { - err.statusCode.should.equal(404); - done(); + function(done) { + var unknownId = uid.fromConnector(db) || 123; + var post = new Post({id: unknownId}); + post.updateAttributes({title: 'updated title', content: 'AAA'}, {validate: false}, (err) => { + should(err).have.property('statusCode', 404); + done(); + }); }); - }); it('works on create if the request does not include an id', function(done) { var post = {title: 'a', content: 'AAA'};