-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 BUGFIX] enable canonical state updates to deleted records #5408
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,11 +16,13 @@ module('unit/model - DS.Model', { | |
beforeEach() { | ||
Person = DS.Model.extend({ | ||
name: DS.attr('string'), | ||
isDrugAddict: DS.attr('boolean') | ||
isDrugAddict: DS.attr('boolean'), | ||
isArchived: DS.attr() | ||
}); | ||
Person.toString = () => 'person'; | ||
|
||
env = setupStore({ | ||
adapter: DS.JSONAPIAdapter, | ||
person: Person | ||
}); | ||
store = env.store; | ||
|
@@ -567,6 +569,52 @@ test('supports pushedData in root.deleted.uncommitted', function(assert) { | |
}); | ||
}); | ||
|
||
test('supports pushedData in root.deleted.saved', function(assert) { | ||
let { adapter } = env; | ||
|
||
adapter.shouldBackgroundReloadRecord = () => false; | ||
adapter.deleteRecord = () => { | ||
return Ember.RSVP.resolve(); | ||
}; | ||
|
||
let record = run(() => store.push({ | ||
data: { | ||
type: 'person', | ||
id: '1', | ||
attributes: { | ||
isArchived: false | ||
} | ||
} | ||
})); | ||
|
||
run(() => { | ||
record.destroyRecord().then(() => { | ||
let currentState = record._internalModel.currentState; | ||
|
||
assert.ok(currentState.stateName === 'root.deleted.saved', | ||
'record is in a persisted deleted state'); | ||
assert.equal(get(record, 'isDeleted'), true); | ||
assert.ok(store.peekRecord('person', '1') !== null, 'the deleted person is not removed from store (no unload called)'); | ||
}); | ||
}); | ||
|
||
run(() => { | ||
try { | ||
store.push({ | ||
data: { | ||
type: 'person', | ||
id: '1', | ||
attributes: { | ||
isArchived: true | ||
} | ||
} | ||
}) | ||
} catch (e) { | ||
assert.ok(false, e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what does this try/catch achieve? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hjdivad oh wait, actually, I can't unless there's a corollary? I basically want a "expect no assertion" |
||
} | ||
}); | ||
}); | ||
|
||
test('currentState is accessible when the record is created', function(assert) { | ||
let hash = { | ||
data: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this try/catch achieve?