Skip to content

Commit

Permalink
Update the defaults for shouldReloadRecord, shouldBackgroundReloadRec…
Browse files Browse the repository at this point in the history
…ord and shouldReloadAll for Ember Data 2.0
  • Loading branch information
bmac committed Jul 1, 2015
1 parent 2bd73ca commit 73ac0ea
Show file tree
Hide file tree
Showing 23 changed files with 274 additions and 121 deletions.
7 changes: 2 additions & 5 deletions packages/ember-data/lib/system/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,7 @@ var Adapter = Ember.Object.extend({
@return {Boolean}
*/
shouldReloadAll: function(store, snapshotRecordArray) {
var modelName = snapshotRecordArray.type.modelName;
Ember.deprecate(`The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "${modelName}" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in your adapter:application and return true.`);
return true;
return !snapshotRecordArray.length;
},

/**
Expand All @@ -504,8 +502,7 @@ var Adapter = Ember.Object.extend({
@return {Boolean}
*/
shouldBackgroundReloadRecord: function(store, snapshot) {
Ember.deprecate('The default behavior of `shouldBackgroundReloadRecord` will change in Ember Data 2.0 to always return true. If you would like to preserve the current behavior please override `shouldBackgroundReloadRecord` in your adapter:application and return false.');
return false;
return true;
},

/**
Expand Down
12 changes: 0 additions & 12 deletions packages/ember-data/tests/integration/adapter/find-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ test("store.find(type) is deprecated", function() {
);
});

test("store.findAll should trigger a deprecation warning about store.shouldReloadAll", function() {
env.adapter.findAll = function() {
return Ember.RSVP.resolve([]);
};

run(function() {
expectDeprecation(function() {
store.findAll('person');
}, 'The default behavior of shouldReloadAll will change in Ember Data 2.0 to always return false when there is at least one "person" record in the store. If you would like to preserve the current behavior please override shouldReloadAll in your adapter:application and return true.');
});
});

test("When a single record is requested, the adapter's find method should be called unless it's loaded.", function() {
expect(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ module("integration/adapter/record_persistence - Persisting Records", {
});
Person.toString = function() { return "Person"; };

env = setupStore({ person: Person });
env = setupStore({
adapter: DS.Adapter.extend({
shouldBackgroundReloadRecord: () => false
}),
person: Person
});
store = env.store;
},

Expand All @@ -50,11 +55,13 @@ test("When a store is committed, the adapter's `commit` method should be called

var tom;

env.store.find('person', 1).then(async(function(person) {
tom = person;
set(tom, "name", "Tom Dale");
tom.save();
}));
run(function() {
env.store.findRecord('person', 1).then(async(function(person) {
tom = person;
set(tom, "name", "Tom Dale");
tom.save();
}));
});
});

test("When a store is committed, the adapter's `commit` method should be called with records that have been created.", function() {
Expand Down
Loading

0 comments on commit 73ac0ea

Please sign in to comment.