Skip to content

Commit 8d7e55f

Browse files
trevorrjohnbmac
authored andcommitted
[BUGFIX beta] pass DS.SnapshotRecordArray to urlForFindAll
(cherry picked from commit 3868436)
1 parent 4016330 commit 8d7e55f

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

addon/-private/adapters/build-url-mixin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default Ember.Mixin.create({
5656
case 'findRecord':
5757
return this.urlForFindRecord(id, modelName, snapshot);
5858
case 'findAll':
59-
return this.urlForFindAll(modelName);
59+
return this.urlForFindAll(modelName, snapshot);
6060
case 'query':
6161
return this.urlForQuery(query, modelName);
6262
case 'queryRecord':
@@ -121,9 +121,10 @@ export default Ember.Mixin.create({
121121
/**
122122
* @method urlForFindAll
123123
* @param {String} modelName
124+
* @param {DS.SnapshotRecordArray} snapshot
124125
* @return {String} url
125126
*/
126-
urlForFindAll(modelName) {
127+
urlForFindAll(modelName, snapshot) {
127128
return this._buildURL(modelName);
128129
},
129130

addon/adapters/rest.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,9 @@ export default Adapter.extend(BuildURLMixin, {
432432
@return {Promise} promise
433433
*/
434434
findAll(store, type, sinceToken, snapshotRecordArray) {
435-
const url = this.buildURL(type.modelName, null, null, 'findAll');
435+
const url = this.buildURL(type.modelName, null, snapshotRecordArray, 'findAll');
436436
const query = this.buildQuery(snapshotRecordArray);
437437

438-
if (sinceToken) {
439-
query.since = sinceToken;
440-
}
441-
442438
return this.ajax(url, 'GET', { data: query });
443439
},
444440

tests/integration/adapter/rest-adapter-test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,11 @@ test("findAll - returning an array populates the array", function(assert) {
10201020
});
10211021

10221022

1023-
test("findAll - passes buildURL the requestType", function(assert) {
1023+
test("findAll - passes buildURL the requestType and snapshot", function(assert) {
1024+
assert.expect(2);
1025+
let adapterOptionsStub = { stub: true };
10241026
adapter.buildURL = function(type, id, snapshot, requestType) {
1027+
assert.equal(snapshot.adapterOptions, adapterOptionsStub);
10251028
return "/" + requestType + "/posts";
10261029
};
10271030

@@ -1032,7 +1035,7 @@ test("findAll - passes buildURL the requestType", function(assert) {
10321035
]
10331036
});
10341037

1035-
store.findAll('post').then(assert.wait(function(posts) {
1038+
store.findAll('post', { adapterOptions: adapterOptionsStub }).then(assert.wait(function(posts) {
10361039
assert.equal(passedUrl, "/findAll/posts");
10371040
}));
10381041
});

tests/unit/adapters/build-url-mixin/build-url-test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ test('buildURL - find requestType delegates to urlForFindRecord', function(asser
4242
});
4343

4444
test('buildURL - findAll requestType delegates to urlForFindAll', function(assert) {
45-
assert.expect(2);
45+
assert.expect(3);
4646
let originalMethod = adapter.urlForFindAll;
47-
adapter.urlForFindAll = function(type) {
47+
let snapshotStub = { snapshot: true };
48+
adapter.urlForFindAll = function(type, snapshot) {
4849
assert.equal(type, 'super-user');
50+
assert.equal(snapshot, snapshotStub);
4951
return originalMethod.apply(this, arguments);
5052
};
51-
assert.equal(adapter.buildURL('super-user', null, null, 'findAll'), '/superUsers');
53+
assert.equal(adapter.buildURL('super-user', null, snapshotStub, 'findAll'), '/superUsers');
5254
});
5355

5456
test('buildURL - query requestType delegates to urlForQuery', function(assert) {

0 commit comments

Comments
 (0)