Functional Test: post - Other controller


#1

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


#2

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.