Merge pull request #812 from clarkorz:fix/nest-remote-path

prepend slash for nested remoting path

Close #812
This commit is contained in:
Miroslav Bajtoš 2014-11-27 09:57:42 +01:00
commit 543e90993c
2 changed files with 16 additions and 0 deletions

View File

@ -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) {

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