Forum: Ruby on Rails Testing controllers where authentication is needed

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
444c7d8579d3389a76c8497f5cb66c13?d=identicon&s=25 goodieboy (Guest)
on 2007-01-27 02:35
(Received via mailing list)

I'm using the restulf_athuentication plugin and have changed it to be
used only by a logged in user (an administrator). So, you have to be
logged in and activated in order to pass the before_filter
:login_required. How do I go about "logging in" when testing?
8310c5a7c769345114597bcdef111488?d=identicon&s=25 Ben Munat (Guest)
on 2007-01-27 08:57
(Received via mailing list)
Put whatever information is needed in the session (user_id?) in your
test's setup method:

@request.session = { :user_id => users(:test_user).id }

That's how I'm doing it anyway.

This topic is locked and can not be replied to.