diff --git a/lib/application.js b/lib/application.js index 7a3abef5f..183693b56 100644 --- a/lib/application.js +++ b/lib/application.js @@ -273,14 +273,14 @@ app.remoteObjects = function () { * @triggers `mounted` events on shared class constructors (models) */ -app.handler = function (type) { +app.handler = function (type, options) { var handlers = this._handlers || (this._handlers = {}); if(handlers[type]) { return handlers[type]; } var remotes = this.remotes(); - var handler = this._handlers[type] = remotes.handler(type); + var handler = this._handlers[type] = remotes.handler(type, options); remotes.classes().forEach(function(sharedClass) { sharedClass.ctor.emit('mounted', app, sharedClass, remotes); diff --git a/lib/models/model.js b/lib/models/model.js index af5581fa3..67278afe1 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -102,12 +102,15 @@ Model.setup = function () { var ModelCtor = this; var options = this.settings; var typeName = this.modelName; - + + var remotingOptions = {}; + extend(remotingOptions, options.remoting || {}); + // create a sharedClass var sharedClass = ModelCtor.sharedClass = new SharedClass( ModelCtor.modelName, ModelCtor, - options.remoting + remotingOptions ); // setup a remoting type converter for this model diff --git a/test/access-token.test.js b/test/access-token.test.js index 94260b8da..670b590ad 100644 --- a/test/access-token.test.js +++ b/test/access-token.test.js @@ -109,7 +109,7 @@ describe('AccessToken', function () { }); describe('app.enableAuth()', function() { - this.timeout(0); + this.timeout(false); beforeEach(createTestingToken); diff --git a/test/app.test.js b/test/app.test.js index 6d5b29378..03839517e 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -350,4 +350,24 @@ describe('app', function() { var app = loopback(); expect(app.loopback).to.equal(loopback); }); + + describe('normalizeHttpPath option', function() { + var app, db; + beforeEach(function() { + app = loopback(); + db = loopback.createDataSource({connector: loopback.Memory}); + }); + + it.onServer('normalizes the http path', function(done) { + var UserAccount = PersistedModel.extend('UserAccount', {name: String}, { + remoting: { normalizeHttpPath: true } + }); + app.model(UserAccount); + UserAccount.attachTo(db); + + app.use(loopback.rest()); + request(app).get('/user-accounts').expect(200, done); + }); + }); + });