-
-
Notifications
You must be signed in to change notification settings - Fork 115
Fix redirect_to inside callback and doesn't call call
method in action
#94
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
Conversation
lib/lotus/action/callbacks.rb
Outdated
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.
Seems to be good candidate for blank? method for utils
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 agree, I could add to https://github.com/lotus/utils/blob/master/lib/lotus/utils/string.rb
Looks good to me |
@donperi mmmm maybe we need, what do you think guys? |
@AlfonsoUceda I have no strong opinion on that, I leave it to @jodosha |
I think it should not be called. If you have an expensive operation that should be called after, it makes no sense to execute that if you redirected. To me, you shouldn't get to that stage where you halted the execution chain yet you had a callback fired for no reason. |
@AlfonsoUceda Thanks for taking care of this 😸 My opinion on this is to keep callbacks as simple as possible. def redirect_to(url, status: 302)
headers[LOCATION] = url
halt(status)
end This will prevent |
ok!, I'm goint to try that ;) |
@jodosha there is a problem doing that. This test [1] fails, errors aren't passed [1] https://github.com/lotus/controller/blob/master/test/integration/full_stack_test.rb#L26 with
|
@jodosha nevermind I got it, I'll update the PR |
👍 |
Fix redirect_to inside callback and doesn't call `call` method in action
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.
@AlfonsoUceda Can you please ensure that the body isn't send, as it's useless?
last_response.body.must_equal ''
Hint: status(302, nil)
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.
ok @jodosha ;) I'll do another PR
This looks great to me! |
fix #93
This PR fixes a problem if a person does a
redirect_to
inside a before callback thecall
method in an action is called.