Ups! I sent the response in a private e-mail instead of making a post
here.
---

are you testing models or controller?

If you are testing the model, you'll have to pass the user in a
method. The method shall then use:

with_acting_user(user) {

yada yada yada

 }


For example:

ChampionshipControllerTest:

def test_viewable_by_admin
   assert_view(:championship_with_games, :admin, true)
end

private
def assert_view(championship_label, viewing_user_label,
expected_result)
   championship = championships(championship_label)
   user = users(viewing_user_label)
   assert_equal expected_result, championship.viewable_by?(user)
end


If you take a closer look at the viewable_by? implemented by Hobo. You
see:


(from permissions.rb)
def viewable_by?(user, attribute=nil)
...
     with_acting_user(user) { view_permitted?(attribute) }
end


To test the controller, you'll have to login the user first using:

post :login, :login => 'championship_manager', :password => 'test'

TF

On Jan 9, 8:20 pm, Steve DeBaun <[email protected]> wrote:
> I want to be able to set acting_user to a specific user during a
> test.  Can this be done easily?
>
> Cheers,
>
> sd
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to