-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix bug where record rejected via find
stayed in loading state
#3043
Merged
igorT
merged 1 commit into
emberjs:master
from
pangratz:fix_isLoading_flag_for_failed_find_request
May 5, 2015
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, it's ok to use private methods like this in the test |
||
// 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"); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line has been added in 63795a4, where the
record
parameter was not available. I guess that's the reason why avar record = store.getById(typeClass, id)
has been used here; therecord
parameter is added in 51728a8. So I think reusing the param down below is save...