Prepend slash for nested remoting paths

Fix remoting paths of relation methods to correctly show
in API Explorer.
This commit is contained in:
Clark Wang 2014-11-14 15:33:29 +08:00 committed by Miroslav Bajtoš
parent b83ded7113
commit a12c2ece28
2 changed files with 16 additions and 0 deletions

View File

@ -619,6 +619,10 @@ Model.nestRemoting = function(relationName, options, cb) {
acceptArgs = []; acceptArgs = [];
} }
if (httpPath[0] !== '/') {
httpPath = '/' + httpPath;
}
// A method should return the method name to use, if it is to be // 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. // included as a nested method - a falsy return value will skip.
var filter = cb || options.filterMethod || function(method, relation) { var filter = cb || options.filterMethod || function(method, relation) {

View File

@ -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(/^\/.*/);
});
});
});
});
}); });
}); });