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

[FEAT] FASTBOOT SHOEBOX - Use actions queue so rehydration works #5439

Merged
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
14 changes: 10 additions & 4 deletions addon/-private/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ Store = Service.extend({

internalModel.loadingData(promise);
if (this._pendingFetch.size === 0) {
emberRun.schedule('afterRender', this, this.flushAllPendingFetches);
emberRun.schedule('actions', this, this.flushAllPendingFetches);
}

this._pendingFetch.get(modelName).push(pendingFetchItem);
Expand Down Expand Up @@ -872,9 +872,15 @@ Store = Service.extend({
}

if (missingInternalModels.length) {
warn('Ember Data expected to find records with the following ids in the adapter response but they were missing: ' + inspect(missingInternalModels.map(r => r.id)), false, {
id: 'ds.store.missing-records-from-adapter'
});
warn(
'Ember Data expected to find records with the following ids in the adapter response but they were missing: [ "' +
missingInternalModels.map(r => r.id).join('", "') +
'" ]',
false,
{
id: 'ds.store.missing-records-from-adapter'
}
);
rejectInternalModels(missingInternalModels);
}
}
Expand Down
62 changes: 35 additions & 27 deletions tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1918,40 +1918,48 @@ test('findBelongsTo - passes buildURL the requestType', function(assert) {
});

testInDebug('coalesceFindRequests assert.warns if the expected records are not returned in the coalesced request', function(assert) {
assert.expect(2);
Comment.reopen({ post: DS.belongsTo('post', { async: false }) });
Post.reopen({ comments: DS.hasMany('comment', { async: true }) });

adapter.coalesceFindRequests = true;

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

let wait;
assert.expectWarning(() => {
run(() => {
store.push({
data: {
type: 'post',
id: '2',
relationships: {
comments: {
data: [
{ type: 'comment', id: '1' },
{ type: 'comment', id: '2' },
{ type: 'comment', id: '3' }
]
}
}
}
});
ajaxResponse({
comments: [
{ id: '1', type: 'comment' }
]
});

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.`)
})
});
let post = run(() => store.push({
data: {
type: 'post',
id: '2',
relationships: {
comments: {
data: [
{ type: 'comment', id: '1'},
{ type: 'comment', id: '2'},
{ type: 'comment', id: '3'}
]
}
}
}
}));

return wait;
}, /expected to find records with the following ids in the adapter response but they were missing: \[2,3\]/);
assert.expectWarning(
() => {
return run(() => {
return 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.`
);
});
});
},
/expected to find records with the following ids in the adapter response but they were missing: \[ "2", "3" \]/
);
});

test('groupRecordsForFindMany groups records based on their url', function(assert) {
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/model-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ test('it should cache attributes', function(assert) {
});

const store = createStore({
adapter: DS.JSONAPIAdapter.extend({
shouldBackgroundReloadRecord: () => false
}),
post: Post
});

Expand All @@ -366,7 +369,7 @@ test('it should cache attributes', function(assert) {
}
});

return store.findRecord('post', 1).then(record => {
return store.findRecord('post', '1').then(record => {
record.set('updatedAt', date);

assert.deepEqual(date, get(record, 'updatedAt'), 'setting a date returns the same date');
Expand Down