Functional Tests and "user_engine" protected actions

I had a quick search on the archive, but actually I did not find
anything useful to me.

My problem is that I need to do some functional tests on controllers
that are restricted to only some kind of users (I’m using user_engine).
While “manually” everything works, I’d like to test it authomatically. I
think I can do it with integration tests on rails 1.1, however for now I
must stick to 1.0.

Is there a “standard” solution to solve my problem? I tried to edit the
session object, but it looks read only. I have the login as user/login
and have to test actions from other controllers. I thought I could add a
login method to the tested controllers in the file where the tests are
defined, but it would be sub-optimal in my opinion.

It is the only way?

blog: |
site: |
forum: |

Riko wrote:

It is the only way?

I found the solution. I have to put an user in the session and it works.
Actually I have to call it @request.session and not just session (the
first one is a TestSession that supports key based insertion, while the
latter is just an Array).

I defined a

def login(user)
@request.session[:user] = user
@request.session[:user].logged_in_at =

method and then call it if I need to simulate authentication. Good.

On 5/30/06, Enrico F. [email protected] wrote:

I found the solution. I have to put an user in the session and it works.

However now that we have integration tests, this kind of testing is
more appropriate there.
We should just disable checking when testing, in my opinion.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs