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: http://www.akropolix.net/rik0/blogs | site: http://www.akropolix.net/rik0/ | forum: http://www.akropolix.net/forum/ |
on 2006-05-30 14:41
on 2006-05-30 18:18
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 = Time.now end method and then call it if I need to simulate authentication. Good.
on 2006-06-23 09:32
On 5/30/06, Enrico Franchi <email@example.com> 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.