diff --git a/lib/models/model.js b/lib/models/model.js index b9b8467c..72b43ebb 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -48,7 +48,7 @@ Model.setup = function () { } else if(data) { fn(null, new ModelCtor(data)); } else if(id) { - ModelCtor.find(id, function (err, model) { + ModelCtor.findById(id, function (err, model) { if(err) { fn(err); } else if(model) { @@ -96,14 +96,14 @@ Model.setup = function () { }); } } - + + // Map the prototype method to /:id with data in the body ModelCtor.sharedCtor.accepts = [ - {arg: 'data', type: 'object', http: {source: 'body'}}, - {arg: 'id', type: 'any', http: {source: 'url'}} + {arg: 'id', type: 'any', http: {source: 'path'}} + // {arg: 'instance', type: 'object', http: {source: 'body'}} ]; ModelCtor.sharedCtor.http = [ - {path: '/'}, {path: '/:id'} ]; diff --git a/test/data-source.test.js b/test/data-source.test.js index f39866a2..ff37f5d2 100644 --- a/test/data-source.test.js +++ b/test/data-source.test.js @@ -44,8 +44,8 @@ describe('DataSource', function() { // - existsAndShared('_forDB', false); existsAndShared('create', true); - existsAndShared('updateOrCreate', false); - existsAndShared('upsert', false); + existsAndShared('updateOrCreate', true); + existsAndShared('upsert', true); existsAndShared('findOrCreate', false); existsAndShared('exists', true); existsAndShared('find', true); @@ -57,10 +57,11 @@ describe('DataSource', function() { existsAndShared('hasMany', false); existsAndShared('belongsTo', false); existsAndShared('hasAndBelongsToMany', false); - existsAndShared('save', true); + existsAndShared('save', false); existsAndShared('isNewRecord', false); existsAndShared('_adapter', false); - existsAndShared('destroy', true); + existsAndShared('destroyById', true); + existsAndShared('destroy', false); existsAndShared('updateAttributes', true); existsAndShared('reload', true); @@ -70,4 +71,4 @@ describe('DataSource', function() { } }); }); -}); \ No newline at end of file +});