Testing controllers where authentication is needed


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?

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.


goodieboy wrote: