This project is archived and is in readonly mode.
#put method does not respect sessions in functional tests
Reported by ronin-35527 (at lighthouseapp) | October 24th, 2008 @ 10:23 AM | in 2.x
In my functional tests I'm testing two actions in two different controllers. The first action "save" in the SettingsController is tested like this:
login_as :quentin
put :save, {}, :settings => [{:id => settings(:site_name).id, :value => "Hello world"}]
assert_redirected_to :controller => "settings", :action => "index"
The #login_as helper method looks like this:
def login_as(user)
@request.session[:user_id] = user ? users(user).id : nil
end
It assigns a session variable to the request. My other action "update" in the PagesController is also tested like above, using the #put method that makes a new PUT request. But the two tests fails and the failure message is similar to this:
expected a redirect to <{"action"=>"index", "controller"=>"settings"}>, found one to <{"action"=>"ne
w", "controller"=>"sessions"}>, a difference of <{"action"=>"new", "controller"=>"sessions"}>
What this actually means is, that there is no "user_id" session variable which must mean that #put doesn't respect sessions. Can anyone confirm this?
Comments and changes to this ticket
-
ronin-35527 (at lighthouseapp) November 21st, 2008 @ 09:17 AM
I just fixed this. It's supposed to look like this:
put :save, :settings => {1 => {:value => "Something"}
The empty curly braces caused :settings to be passed as a session variable, overriding the :user_id session variable. Never mind :)
-
josh December 15th, 2008 @ 09:33 PM
- State changed from new to invalid
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
- Nobody is watching this ticket.