
Follow redirect after POST
Reported by Mark Dodwell | May 23rd, 2008 @ 07:30 PM
When you post a login controller action that successfully logins sends a redirect webrat does not to follow the redirected URL.
For example, with a controller with the following:
def login
if user = User.authenticate(params['username'], params['password'])
session[:user_id] = user.id
redirect_to 'admin/dashboard'
else
flash[:notice] = "Login unsuccessful."
end
end
doing:
post '/admin/login', { 'username' => 'joe', 'password' => '1234' }
is not the same as doing this:
post '/admin/login', { 'username' => 'joe', 'password' => '1234' }
get 'admin/dashboard'
I believe this is a bug.
Comments and changes to this ticket
-
Mark Dodwell May 23rd, 2008 @ 07:32 PM
Sorry please delete that ticket -- it's nothing to do with webrat these methods are from Rails. Too late...
-
Peter Jaros October 10th, 2008 @ 12:33 PM
@Mark
I'm hitting the same issue. Is there a Rails bug this corresponds to?
-
Mark Dodwell October 10th, 2008 @ 12:44 PM
Hi Peter -- it's not a bug actually.
If you want Rails to follow any redirect you have to append '_via_redirect' to the end of your (get|post|delete|put) method call.
See the Rails API doc for more info:
http://www.railsbrain.com/api/ra...
Hope that helps!
~ Mark
-
Mark Dodwell October 10th, 2008 @ 12:46 PM
Just realized that link doesn't work, anyway sure you get the idea! This one works:
-
Bryan Helmkamp October 21st, 2008 @ 11:41 PM
- State changed from new to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Ruby Acceptance Testing for Web applications.