Skip to content
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

Update shouldReload* flags for 2.0 #3469

Merged
merged 1 commit into from
Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -31,18 +31,6 @@ test("It raises an assertion when `undefined` is passed as id (#1705)", function
}, "You cannot pass `null` as id to the store's find method");
});

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 Down Expand Up @@ -58,11 +63,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