Skip to content

Commit

Permalink
When resetting the subset, repopulate with filtered models from the p…
Browse files Browse the repository at this point in the history
…arent.

All models in the subset should be the same instance as in the parent
collection. Corrected test to reflect this.
  • Loading branch information
Saimon Moore committed Nov 30, 2011
1 parent 77f88d7 commit ed282a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions backbone.subset.js
Expand Up @@ -74,8 +74,10 @@
this.each(this._unbindModelEvents);
this._reset();

_.each(models, function (model) {
this._addToSubset(model, {silent: true});
this.parent().each(function (model) {
if (this.sieve(model)) {
this._addToSubset(model, {silent: true});
}
}, this);

if (!options.silent) {
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Expand Up @@ -190,6 +190,6 @@ describe('Aggregated collections', function () {
assert.deepEqual(tasks.pluck('id'), [0, 4, 5]);
assert.deepEqual(archived_tasks.pluck('id'), [5]);
assert.deepEqual(_.pluck(tasks.models, 'cid'), ['c6', 'c8', 'c9']);
assert.deepEqual(_.pluck(archived_tasks.models, 'cid'), ['c11']);
assert.deepEqual(_.pluck(archived_tasks.models, 'cid'), ['c9']);
});
});

0 comments on commit ed282a9

Please sign in to comment.