Accessing the params hash in a functional test not working


#1

I am having problems reading params in a functional test (Rails 1.1.2).
My
test looks like this:

fixtures :users

def test_auth_bob
@request.session[:return_to] = “/bogus/location”
post :login, :user => { :email => “removed_email_address@domain.invalid”, :password =>
“test”
}

assert_session_has :user
assert_equal @bob, @response.session[:user]
assert_redirected_to "/bogus/location"

end

And the login action looks like:

def login
session[:debug_params] = params
case @request.method
when :post
if session[:user] = User.authenticate(params[:user_email],
params[:user_password])
flash[:notice] = "You are now logged in as
"+session[:user].fullname
redirect_back_or_default :action => “welcome”
else
flash[:error] = “The email address and/or password you entered
is
invalid.”.t
redirect_back_or_default :action => “login”
end
end
end

The test fails as follows. Note that session[:debug_params] is missing
the
parameters sent by post.

  1. Failure:
    test_auth_bob(UserControllerTest)
    [c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1
    /lib/action_controller/depr
    ecated_assertions.rb:23:in assert_session_has' ./test/functional/user_controller_test.rb:25:intest_auth_bob’]:
    <:user> is not in the session <#<ActionController::TestSession:0x36a8380
    @attributes=
    {:user=>nil,
    :debug_params=>{“action”=>“login”},
    “flash”=>
    {:error=>“The email address and/or password you entered is
    invalid.”},
    :return_to=>nil}>>

I am stumped figuring out why the params are not being passed through -
any
help appreciated!

Cheers,

Dan.