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

Reset Model#isReloading to false when request fails #3037

Merged
merged 1 commit into from
May 3, 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
2 changes: 1 addition & 1 deletion packages/ember-data/lib/system/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1099,13 +1099,13 @@ var Model = Ember.Object.extend(Ember.Evented, {
var promise = new Promise(function(resolve) {
record.send('reloadRecord', resolve);
}, promiseLabel).then(function() {
record.set('isReloading', false);
record.set('isError', false);
return record;
}, function(reason) {
record.set('isError', true);
throw reason;
}, "DS: Model#reload complete, update flags")['finally'](function () {
record.set('isReloading', false);
record.updateRecordArrays();
});

Expand Down
3 changes: 3 additions & 0 deletions packages/ember-data/tests/integration/records/reload-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ test("When a record is reloaded and fails, it can try again", function() {

var count = 0;
env.adapter.find = function(store, type, id, snapshot) {
equal(tom.get('isReloading'), true, "Tom is reloading");
if (count++ === 0) {
return Ember.RSVP.reject();
} else {
Expand All @@ -69,10 +70,12 @@ test("When a record is reloaded and fails, it can try again", function() {
run(function() {
tom.reload().then(null, function() {
equal(tom.get('isError'), true, "Tom is now errored");
equal(tom.get('isReloading'), false, "Tom is no longer reloading");
return tom.reload();
}).then(function(person) {
equal(person, tom, "The resolved value is the record");
equal(tom.get('isError'), false, "Tom is no longer errored");
equal(tom.get('isReloading'), false, "Tom is no longer reloading");
equal(tom.get('name'), "Thomas Dale", "the updates apply");
});
});
Expand Down