Skip to content

Commit

Permalink
Merge pull request #2956 from runspired/master
Browse files Browse the repository at this point in the history
Clear meta data when unloading all records for a type. Fixes #2772
  • Loading branch information
igorT committed Mar 31, 2015
2 parents 40921e0 + a7dd2d3 commit e1887fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/ember-data/lib/system/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ Store = Service.extend({
}

typeMap.findAllCache = null;
typeMap.metadata = Ember.create(null);
},

/**
Expand Down
18 changes: 18 additions & 0 deletions packages/ember-data/tests/integration/records/unload-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ test("can unload all records for a given type", function () {
equal(env.store.all('person').get('length'), 0);
});

test("Unloading all records for a given type clears saved meta data.", function () {

function metadataKeys(type) {
return Ember.keys(env.store.metadataFor(type));
}

run(function() {
env.store.setMetadataFor('person', { count: 10 });
});

Ember.run(function() {
env.store.unloadAll('person');
});

deepEqual(metadataKeys('person'), [], 'Metadata for person is empty');

});

test("removes findAllCache after unloading all records", function () {
var adam, bob;
run(function() {
Expand Down

0 comments on commit e1887fd

Please sign in to comment.