[Rails] Functional Test Problem. Nubee, please help

Eric Goodwin
Thu, 27 Apr 2006 21:21:43 -0000

Hi,
You can pass an object as a third parameter that contains the data that would be
in you session.
Since I''m using activeRbac all I need is a rbac_user with a couple
roles to get past my login system.

----------------------------------------
fixtures :users, :roles

def test_index
    get :index, {}, {:rbac_user => get_user}
    assert_response :success
    assert_template ''index''
end

private

def get_user
    user = users(:testuser001)
    user.roles.push roles(:Admin)
    user.roles.push roles(:User)
end
-----------------------------------------

- Eric



Allen wrote:
> ALl my controllers require the user to be logged in.  SO they will be
> redirected to my "login" controller.
>
> How do i login first in a functional test?  Im assuming i use the setup
> method to login the controller.
>
> This is the setup method for the Activities controller functional test:
>
>   def setup
>     @controller = ActivitiesController.new
>     @request    = ActionController::TestRequest.new
>     @response   = ActionController::TestResponse.new
>   end
>
> my "login" controller has a method "authenticate" which
needs
> params[:username] and params[:password].  Please help!
>
> Thanks
> Allen
>
>


--
Eric Goodwin