Skip to content

Commit

Permalink
reject with useful reason, rather then undefined when a scheduled fet…
Browse files Browse the repository at this point in the history
…ch fails to contain an expected record.
  • Loading branch information
stefanpenner committed Mar 3, 2017
1 parent 7f590d8 commit 77583a7
Show file tree
Hide file tree
Showing 3 changed files with 340 additions and 350 deletions.
5 changes: 3 additions & 2 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,11 @@ Store = Service.extend({

function rejectInternalModels(internalModels, error) {
for (let i = 0, l = internalModels.length; i < l; i++) {
let pair = seeking[internalModels[i].id];
let internalModel = internalModels[i];
let pair = seeking[internalModel.id];

if (pair) {
pair.resolver.reject(error);
pair.resolver.reject(error || new Error(`Expected: '${internalModel}' to be present in the adapter provided payload, but it was not found.`));
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1947,10 +1947,10 @@ testInDebug('coalesceFindRequests assert.warns if the expected records are not r
adapter.coalesceFindRequests = true;

ajaxResponse({ comments: [{ id: 1 }] });
var post;

assert.expectWarning(function() {
run(function() {
let wait;
assert.expectWarning(() => {
run(() => {
store.push({
data: {
type: 'post',
Expand All @@ -1967,9 +1967,13 @@ testInDebug('coalesceFindRequests assert.warns if the expected records are not r
}
});

post = store.peekRecord('post', 2);
post.get('comments');
let post = store.peekRecord('post', 2);
wait = post.get('comments').catch(e => {
assert.equal(e.message, `Expected: '<comment:2>' to be present in the adapter provided payload, but it was not found.`)
})
});

return wait;
}, /expected to find records with the following ids in the adapter response but they were missing: \[2,3\]/);
});

Expand Down
Loading

0 comments on commit 77583a7

Please sign in to comment.