diff --git a/addon/-private/adapters/build-url-mixin.js b/addon/-private/adapters/build-url-mixin.js index cdded53d58a..4d8ca008346 100644 --- a/addon/-private/adapters/build-url-mixin.js +++ b/addon/-private/adapters/build-url-mixin.js @@ -56,7 +56,7 @@ export default Ember.Mixin.create({ case 'findRecord': return this.urlForFindRecord(id, modelName, snapshot); case 'findAll': - return this.urlForFindAll(modelName); + return this.urlForFindAll(modelName, snapshot); case 'query': return this.urlForQuery(query, modelName); case 'queryRecord': @@ -121,9 +121,10 @@ export default Ember.Mixin.create({ /** * @method urlForFindAll * @param {String} modelName + * @param {DS.SnapshotRecordArray} snapshot * @return {String} url */ - urlForFindAll(modelName) { + urlForFindAll(modelName, snapshot) { return this._buildURL(modelName); }, diff --git a/addon/adapters/rest.js b/addon/adapters/rest.js index 26285e6d782..b7628fe55a2 100644 --- a/addon/adapters/rest.js +++ b/addon/adapters/rest.js @@ -458,7 +458,7 @@ var RESTAdapter = Adapter.extend(BuildURLMixin, { return this._makeRequest(request); } else { - const url = this.buildURL(type.modelName, null, null, 'findAll'); + const url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll'); if (sinceToken) { query.since = sinceToken; diff --git a/tests/integration/adapter/rest-adapter-test.js b/tests/integration/adapter/rest-adapter-test.js index ffac75b484e..8967521d13e 100644 --- a/tests/integration/adapter/rest-adapter-test.js +++ b/tests/integration/adapter/rest-adapter-test.js @@ -1033,8 +1033,11 @@ test("findAll - returning an array populates the array", function(assert) { }); -test("findAll - passes buildURL the requestType", function(assert) { +test("findAll - passes buildURL the requestType and snapshot", function(assert) { + assert.expect(2); + let adapterOptionsStub = { stub: true }; adapter.buildURL = function(type, id, snapshot, requestType) { + assert.equal(snapshot.adapterOptions, adapterOptionsStub); return "/" + requestType + "/posts"; }; @@ -1045,7 +1048,7 @@ test("findAll - passes buildURL the requestType", function(assert) { ] }); - store.findAll('post').then(assert.wait(function(posts) { + store.findAll('post', { adapterOptions: adapterOptionsStub }).then(assert.wait(function(posts) { assert.equal(passedUrl, "/findAll/posts"); })); }); diff --git a/tests/unit/adapters/build-url-mixin/build-url-test.js b/tests/unit/adapters/build-url-mixin/build-url-test.js index 866fcf787b7..152bba1e9dc 100644 --- a/tests/unit/adapters/build-url-mixin/build-url-test.js +++ b/tests/unit/adapters/build-url-mixin/build-url-test.js @@ -42,13 +42,15 @@ test('buildURL - find requestType delegates to urlForFindRecord', function(asser }); test('buildURL - findAll requestType delegates to urlForFindAll', function(assert) { - assert.expect(2); + assert.expect(3); let originalMethod = adapter.urlForFindAll; - adapter.urlForFindAll = function(type) { + let snapshotStub = { snapshot: true }; + adapter.urlForFindAll = function(type, snapshot) { assert.equal(type, 'super-user'); + assert.equal(snapshot, snapshotStub); return originalMethod.apply(this, arguments); }; - assert.equal(adapter.buildURL('super-user', null, null, 'findAll'), '/superUsers'); + assert.equal(adapter.buildURL('super-user', null, snapshotStub, 'findAll'), '/superUsers'); }); test('buildURL - query requestType delegates to urlForQuery', function(assert) {