Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

#put method does not respect sessions in functional tests

#1263

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?

Reported by ronin-35527 (at lighthouseapp) · October 24th, 2008 @ 10:23 AM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. ronin-35527 (at lighthouseapp)
    ronin-35527 (at lighthouseapp)

    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 :)

    November 21st, 2008 @ 09:17 AM

  2. josh
    josh
    • State changed from new to invalid

    December 15th, 2008 @ 09:33 PM