Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup + reject with useful reasons #4836

Merged
merged 1 commit into from
Mar 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.`));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only change to ember-data, previously undefined was throw, now it is an error with a actionable message.

}
}
}
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