diff --git a/apidocs/describe-builtin-models.js b/apidocs/describe-builtin-models.js index 1b17115..19a5666 100644 --- a/apidocs/describe-builtin-models.js +++ b/apidocs/describe-builtin-models.js @@ -25,7 +25,7 @@ console.log('Generating API docs for LoopBack built-in models.'); var app = loopback(); -app.dataSource('db', { connector: 'memory', defaultForType: 'db' }); +app.dataSource('db', { connector: 'memory' }); var modelNames = []; for (var key in loopback) { diff --git a/lib/services.template.ejs b/lib/services.template.ejs index 77dbf88..59aa356 100644 --- a/lib/services.template.ejs +++ b/lib/services.template.ejs @@ -180,6 +180,12 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && (action.sharedMethod.aliases || []).forEach(function(alias) { var aliasMethod = alias.split('.').join('$'); + // this is to handle strong-remoting does not prepend prototype. + // back into prototype methods + if (action.sharedMethod.isStatic === false) { + aliasMethod = ['prototype', aliasMethod].join('$'); + } + ngdocForMethod(modelName, aliasMethod, action); -%> R[<%-: aliasMethod | q %>] = R[<%-: methodName | q %>]; <% }); // aliases.foreach diff --git a/package.json b/package.json index 7ea20a4..377e568 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "karma-mocha-reporter": "^1.1.5", "karma-phantomjs-launcher": "^1.0.1", "karma-requirejs": "^0.2.1", - "loopback": "^2.0", - "loopback-datasource-juggler": "^2.0", + "loopback": "^3.0", + "loopback-datasource-juggler": "^3.0", "mocha": "~1.18.0", "morgan": "^1.2", "phantomjs-prebuilt": "^2.1.7", diff --git a/test.e2e/spec/services.spec.js b/test.e2e/spec/services.spec.js index 7dedd33..b1bc696 100644 --- a/test.e2e/spec/services.spec.js +++ b/test.e2e/spec/services.spec.js @@ -443,6 +443,7 @@ define(['angular', 'given', 'util'], function(angular, given, util) { 'deleteById', 'removeById', 'count', + 'prototype$patchAttributes', 'prototype$updateAttributes', ]); }); @@ -917,7 +918,6 @@ define(['angular', 'given', 'util'], function(angular, given, util) { app.models.Product.create({ name: 'p1' }, function(err, prod) { if (err) return cb(err); debug('Created product', prod); - prod.categories.create({ name: 'c1' }, function(err, cat) { if (err) return cb(err); debug('Created category', cat); diff --git a/test.e2e/test-server.js b/test.e2e/test-server.js index 93068b3..d453be8 100644 --- a/test.e2e/test-server.js +++ b/test.e2e/test-server.js @@ -81,19 +81,26 @@ masterApp.post('/setup', function(req, res, next) { lbApp = loopback(); - lbApp.dataSource('db', { connector: 'memory', defaultForType: 'db' }); - lbApp.dataSource('mail', { connector: 'mail', defaultForType: 'mail' }); + lbApp.dataSource('db', { connector: 'memory' }); for (var m in models) { - models[m].dataSource = 'db'; - var model = initialModels[m]; - lbApp.model(model || m, models[m]); + var model = null; + var options = models[m].options || {}; + if (initialModels[m]) { + model = initialModels[m]; + lbApp.model(model, extend({ dataSource: 'db' }, options)); + } else { + model = lbApp.registry.createModel( + m, + models[m].properties || {}, + options + ); + lbApp.model(model, { dataSource: 'db' }); + } } - loopback.autoAttach(); - if (enableAuth) - lbApp.enableAuth(); + lbApp.enableAuth({ dataSource: 'db' }); lbApp.set('restApiRoot', '/'); lbApp.use(lbApp.get('restApiRoot'), loopback.rest());