Forum: Ruby on Rails Functional Test: post - Other controller

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Doug B. (Guest)
on 2006-03-21 14:37
(Received via mailing list)
Hi All

I'm attempting to get all of my tests clear after installing the Salted
Hash
Login generator.  Now I've protected the entire application so login is
required from all points.  However I get a fail 302 on all other
protected
controllers as I haven't explicitly logged in and got the session.

I thought adding the following to the beginning of my methods in the
other
controllers would be ok:

post :login, "user" => { "login" => "username", "password" => "testpass"
}
assert_session_has "user"

However, it assumes the current controller being tested.  How do I go
through the other login/user controller before running through these
tests
requiring user session data?

Is there a way of simply setting the session data to bypass that test?

Would much appreciate your help as I feeel I'm making strides on this
now
but just need to get over this little hurdle.

All the best

Doug
Tom M. (Guest)
on 2006-03-21 18:38
(Received via mailing list)
get and post allow a third parameter: a hash that is the session.

So, pass in what SHLG expects to see in the session for an auth'd
user, and your tests will pass.

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