diff --git a/addon/adapters/application.js b/addon/adapters/application.js index d07ad84..8eb34a4 100644 --- a/addon/adapters/application.js +++ b/addon/adapters/application.js @@ -118,23 +118,23 @@ export default Ember.Object.extend(FetchMixin, Evented, { service.findRelated('photographer', '/api/v1/photos/1/relationships/photographer'); ``` - Or, with option to find releated resource using a different service + Or, with option to find related resource using a different service ```js - service.findRelated({resource: 'photographer', type: 'people'}, url); + service.findRelated({relation: 'photographer', type: 'people'}, url); ``` @method findRelated - @param {String|Object} resource name to lookup the service object w/ serializer - @param {String} resource.resource the name of the resource + @param {String|Object} relation name to lookup the service object w/ serializer + @param {String} relation.relation the name of the relationship @param {String} resource.type the name of the resource @param {String} url @return {Promise} */ - findRelated(resource, url) { - let type = resource; + findRelated(relation, url) { + let type = relation; if (typeof type === 'object') { - type = resource.type; + type = relation.type; } // use resource's service if in container, otherwise use this service to fetch let service = getOwner(this).lookup('service:' + pluralize(type)) || this; diff --git a/addon/utils/related-proxy.js b/addon/utils/related-proxy.js index ce93805..7a9d7fd 100644 --- a/addon/utils/related-proxy.js +++ b/addon/utils/related-proxy.js @@ -87,7 +87,7 @@ const RelatedProxyUtil = Ember.Object.extend({ let owner = Ember.getOwner(resource); let service = owner.lookup('service:' + pluralize(type)); let promise = this.promiseFromCache(resource, relation, service); - promise = promise || service.findRelated({'resource': relation, 'type': type}, url); + promise = promise || service.findRelated({'relation': relation, 'type': type}, url); let proxyProto = proxyFactory.extend(Ember.PromiseProxyMixin, { 'promise': promise, 'type': relation, 'kind': kind }); diff --git a/tests/unit/adapters/application-test.js b/tests/unit/adapters/application-test.js index 1931d9a..795dc99 100644 --- a/tests/unit/adapters/application-test.js +++ b/tests/unit/adapters/application-test.js @@ -272,7 +272,7 @@ test('#findRelated', function(assert) { }); }); -test('#findRelated is called with optional type for the resource', function (assert) { +test('#findRelated is called with optional type for the relation', function (assert) { assert.expect(4); const done = assert.async(); @@ -295,7 +295,7 @@ test('#findRelated is called with optional type for the resource', function (ass let url = supervisor.get('relationships.direct-reports.links.related'); supervisor.get('directReports').then(() => { assert.ok(stub.calledOnce, 'employees service findRelated method called once'); - assert.equal(stub.firstCall.args[0].resource, 'direct-reports', 'findRelated called with "direct-reports" resource'); + assert.equal(stub.firstCall.args[0].relation, 'direct-reports', 'findRelated called with "direct-reports" relation'); assert.equal(stub.firstCall.args[0].type, 'employees', 'findRelated called with employees type'); assert.equal(stub.firstCall.args[1], url, 'findRelated called with url, ' + url); done();