Functional testing controllers that rely authentication

I have this login scheme in my application.rb controller that looks like this: (pretty must straight from the rails recipes book):

def check_authorization            @user=User.find(session[:user])

           unless @user.roles.detect {|role|                role.rights.detect{|right|                        right.action == action_name && right.controller == self.class.controller_path                    }                }

               render :text => "You are not authroized to preform this action", :status => 403                return false            end     end

This works fine, but It makes it hard for me to functional test my controllers. Because now when I run my functional tests they all fail with 403 authentication errors.

How can I login on my functional tests ?

I have this login scheme in my application.rb controller that looks like this: (pretty must straight from the rails recipes book):

def check_authorization @user=User.find(session[:user])

       unless @user.roles.detect {|role|
           role.rights.detect{|right|
                   right.action == action_name &&

right.controller == self.class.controller_path }

           }

           render :text => "You are not authroized to preform this

action", :status => 403 return false end end

This works fine, but It makes it hard for me to functional test my

controllers. Because now when I run my functional tests they all fail with 403 authentication errors.

How can I login on my functional tests ?

session[:user] = 1

end

I have this login scheme in my application.rb controller that looks like this: (pretty must straight from the rails recipes book):

def check_authorization @user=User.find(session[:user])

       unless @user.roles.detect {|role|
           role.rights.detect{|right|
                   right.action == action_name &&

right.controller == self.class.controller_path }

           }

           render :text => "You are not authroized to preform this

action", :status => 403 return false end end

This works fine, but It makes it hard for me to functional test my

controllers. Because now when I run my functional tests they all fail with 403 authentication errors.

How can I login on my functional tests ?

session[:user] = 1

end

Sorry

def setup [ default setup stuff here]

@request.session[:user] = 1

end

Thanks,

Also for anyone out there, don't forget to include any fixtures that you code will you at any point during this test. For me that was including the rights & roles fixtures that my authentication controller uses.