Forum: Ruby on Rails Trouble with functional tests

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jeff C. (Guest)
on 2007-02-08 21:28
I'm having trouble making my functional tests work.  I'm trying to
simulate an action performed while a user is logged in, but it only
redirects me to the signin page as if no user was logged in.

Here's my functional test:

  def test_signout_with_valid_user
    get :signout, {}, { :user => users(:jeff).id }
    assert_redirected_to home_path

The first user in my users.yml fixtures file is named jeff, with an id
of 1.

Here's my admin controller's signout method:

  before_filter :check_authentication, :except => [:signin, :show,

  def signout
    session[:user] = nil
    session[:intended_action] = nil
    redirect_to home_path

Here's my application.rb check_authentication method:

  def check_authentication
    unless session[:user]
      session[:intended_action] = params
      redirect_to signin_path

When I use the actual application, it works fine--I'm able to sign in,
sign out, everything works as expected.  But when I run the functional
test, I get:

response is not a redirection to all of the options supplied
(redirection is <{"
action"=>"signin", "controller"=>"admin"}>), difference:
<{"action"=>"index", "c

What am I doing wrong?  As far as I can tell, I'm following exactly how
it's described in Agile Web Dev v2, page 194.

Any help would be great.  Thanks!

Jason R. (Guest)
on 2007-02-08 21:32
(Received via mailing list)
Use @request.session instead of parameters to #get.

Jeff C. (Guest)
on 2007-02-08 21:35
Jason R. wrote:
> Use @request.session instead of parameters to #get.
> Jason

Thanks, that worked!

Is the Agile Web Dev book outdated already?  Sigh.

Thomas M. (Guest)
on 2007-02-28 17:57
(Received via mailing list)
is using @request.session a workaround or is that the new correct

is get :signout, {}, { :user => users(:jeff).id }  deprecated in

i had read that get :signout, {}, { :user => users(:jeff).id }  not
working was a bug and will be fixed in 1.2.3, but if i shouldn't be
using that syntax anyway because it is deprecated then i will move my
tests to the new syntax.

thank you, in advance.

On Feb 8, 2:35 pm, Jeff <removed_email_address@domain.invalid>
Jason R. (Guest)
on 2007-03-02 21:11
(Received via mailing list)
It's a bug and will (is?) fixed in Rail 1.2.3

Thomas M. (Guest)
on 2007-03-02 21:24
(Received via mailing list)
Okay, thank you.

On 3/2/07, Jason R. <removed_email_address@domain.invalid> wrote:
> >
> > On Feb 8, 2:35 pm, Jeff <
> > >
> > > Jeff
> > >
> > > --
> > > Posted via
> >
> >
> > > >
> >

Thomas M.
This topic is locked and can not be replied to.