-
Notifications
You must be signed in to change notification settings - Fork 606
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
Do not run prefilter actions if authorizer is destroyed. #191
Conversation
@@ -138,6 +138,7 @@ var setup = function(container, application, options) { | |||
if (!!authorizer) { | |||
authorizer.set('session', session); | |||
Ember.$.ajaxPrefilter(function(options, originalOptions, jqXHR) { | |||
if (authorizer.isDestroyed) { return; } |
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.
I'd move that to line 138
if (!!authorizer && !authorizer.isDestroyed) {
Can you also add a test for that?
@marcoow that line can't be move there. The check is to ensure that while the pre-filter is still installed, that it doesn't actually do anything when the authorizer has been destroyed. I've pushed an integration test to cover this. I didn't want to mock anything out, so I had to use a private call to As a separate note, the pre-filter is capturing the authorizer within its scope. This means that each time you call |
Ah sorry, you're right. Can you create a simple test here though and just mock the |
@marcoow done. |
Cool, the integration test isn't really needed then though. |
@marcoow ok, I removed it. |
merged: 5b71680 |
This probably wouldn't affect a production application, but in testing if you create new containers to test with (or if you reset your application), you could end up with many pre-filters set up. Since there's no way to remove a pre-filter, I think this is a good way to keep them from running once the authorizer and container are no longer in use.