diff --git a/lib/model.js b/lib/model.js index f6a3e9af..8b55c5d4 100644 --- a/lib/model.js +++ b/lib/model.js @@ -619,6 +619,10 @@ Model.nestRemoting = function(relationName, options, cb) { acceptArgs = []; } + if (httpPath[0] !== '/') { + httpPath = '/' + httpPath; + } + // A method should return the method name to use, if it is to be // included as a nested method - a falsy return value will skip. var filter = cb || options.filterMethod || function(method, relation) { diff --git a/test/relations.integration.js b/test/relations.integration.js index 25157be1..4ba459f2 100644 --- a/test/relations.integration.js +++ b/test/relations.integration.js @@ -1293,6 +1293,18 @@ describe('relations - integration', function() { }); }); + it('should have proper http.path for remoting', function() { + [app.models.Book, app.models.Image].forEach(function(Model) { + Model.sharedClass.methods().forEach(function(method) { + var http = Array.isArray(method.http) ? method.http : [method.http]; + http.forEach(function(opt) { + // destroyAll has been shared but missing http property + if (opt.path === undefined) return; + expect(opt.path, method.stringName).to.match(/^\/.*/); + }); + }); + }); + }); }); });