-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3043 from pangratz/fix_isLoading_flag_for_failed_…
…find_request Fix bug where record rejected via `find` stayed in loading state
- Loading branch information
Showing
2 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/ember-data/tests/integration/records/load-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var hasMany = DS.hasMany; | ||
var Post, Comment, env; | ||
var run = Ember.run; | ||
|
||
module("integration/load - Loading Records", { | ||
setup: function() { | ||
Post = DS.Model.extend({ | ||
comments: hasMany({ async: true }) | ||
}); | ||
|
||
Comment = DS.Model.extend(); | ||
|
||
Post.toString = function() { return "Post"; }; | ||
Comment.toString = function() { return "Comment"; }; | ||
|
||
env = setupStore({ post: Post, comment: Comment }); | ||
}, | ||
|
||
teardown: function() { | ||
run(env.container, 'destroy'); | ||
} | ||
}); | ||
|
||
test("When loading a record fails, the isLoading is set to false", function() { | ||
env.adapter.find = function(store, type, id, snapshot) { | ||
return Ember.RSVP.reject(); | ||
}; | ||
|
||
run(function() { | ||
env.store.find('post', 1).then(null, function() { | ||
// store.recordForId is private, but there is currently no other way to | ||
// get the specific record instance, since it is not passed to this | ||
// rejection handler | ||
var post = env.store.recordForId('post', 1); | ||
|
||
equal(post.get("isLoading"), false, "post is not loading anymore"); | ||
}); | ||
}); | ||
}); |