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?