From 18c647a9bbfa9a9e5c2edc468e2310ca7aeb3528 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Tue, 5 Aug 2014 09:10:43 +0200 Subject: [PATCH] Changed options.path to options.http.path --- lib/models/model.js | 8 ++++---- test/relations.integration.js | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/models/model.js b/lib/models/model.js index cafa8bd2..7fad476b 100644 --- a/lib/models/model.js +++ b/lib/models/model.js @@ -345,7 +345,7 @@ Model.remoteMethod = function(name, options) { Model.belongsToRemoting = function(relationName, relation, define) { var fn = this.prototype[relationName]; - var pathName = relation.options.path || relationName; + var pathName = (relation.options.http && relation.options.http.path) || relationName; define('__get__' + relationName, { isStatic: false, http: {verb: 'get', path: '/' + pathName}, @@ -357,7 +357,7 @@ Model.belongsToRemoting = function(relationName, relation, define) { Model.hasOneRemoting = function(relationName, relation, define) { var fn = this.prototype[relationName]; - var pathName = relation.options.path || relationName; + var pathName = (relation.options.http && relation.options.http.path) || relationName; define('__get__' + relationName, { isStatic: false, http: {verb: 'get', path: '/' + pathName}, @@ -368,7 +368,7 @@ Model.hasOneRemoting = function(relationName, relation, define) { } Model.hasManyRemoting = function (relationName, relation, define) { - var pathName = relation.options.path || relationName; + var pathName = (relation.options.http && relation.options.http.path) || relationName; var toModelName = relation.modelTo.modelName; var findByIdFunc = this.prototype['__findById__' + relationName]; @@ -463,7 +463,7 @@ Model.hasManyRemoting = function (relationName, relation, define) { }; Model.scopeRemoting = function(relationName, relation, define) { - var pathName = relation.options.path || relationName; + var pathName = (relation.options.http && relation.options.http.path) || relationName; var toModelName = relation.modelTo.modelName; define('__get__' + relationName, { diff --git a/test/relations.integration.js b/test/relations.integration.js index 2ac601f5..ff7e36ff 100644 --- a/test/relations.integration.js +++ b/test/relations.integration.js @@ -657,7 +657,9 @@ describe('relations - integration', function () { ); recipe.referencesMany(ingredient); // contrived example for test: - recipe.hasOne(photo, { as: 'picture', options: { path: 'image' } }); + recipe.hasOne(photo, { as: 'picture', options: { + http: { path: 'image' } + } }); }); before(function createRecipe(done) {