# http://weblog.jamisbuck.org/2006/3/9/integration-testing-in-rails-1-1# describes some cool integration testing, but there's no# solution for how to 'inject' a user into the system when all # you have is hashed passwords.# The code below lets you inject a user object directly into your# 'session' object.

# So you can add the following methods to your integration test (see the above blog# for more explanation):## def new_session_as( user )# new_session do | sess | # new_session is defined per the blog post above# sess.user_object = user # aha this is where we inject the user object# yield sess if block_given?# end# end

# extract the user object from the mock cgi class, and # set it up in our sessionActionController::CgiRequest.class_eval { alias initialize_for_real initialize def initialize( cgi, options ) initialize_for_real( cgi,options ) # The following line may be different for you: self.session['user'] = cgi.user_object end}