Skip to content

Commit

Permalink
Do not re-add deleted records to a hasMany relationship.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmac committed Jan 24, 2015
1 parent e3029e3 commit ad294de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/ember-data/lib/system/record_arrays/many_array.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export default Ember.Object.extend(Ember.MutableArray, Ember.Evented, {

flushCanonical: function() {
//TODO make this smarter, currently its plenty stupid
var toSet = this.canonicalState.slice(0);
var toSet = this.canonicalState.slice(0).filter(function(record) {
return !record.get('isDeleted');
});

//a hack for not removing new records
//TODO remove once we have proper diffing
var newRecords = this.currentState.filter(function(record) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,15 +1235,15 @@ test('unloading a record with associated records does not prevent the store from
}
});

test("adding and removing records from hasMany relationship #2666", function(){
test("adding and removing records from hasMany relationship #2666", function() {
expect(4);

var Post = DS.Model.extend({
comments: DS.hasMany('comment', { async: true })
});
Post.reopenClass({
FIXTURES: [
{ id: 1, comments: [ 1, 2, 3 ] }
{ id: 1, comments: [1, 2, 3] }
]
});

Expand Down

0 comments on commit ad294de

Please sign in to comment.