views:

14

answers:

1

I am using Clearance for authentication with my rails app which works. But now all my unit tests fail because they redirect to the sign in page, which makes sense. Clearance seems to have helper functions for fixing that but I can only find them for Shoulda. Are there equivalent helpers for Test::Unit?

A: 

I thought there'd be more 'magic' to how the shoulda macros work but it's actually really simple. To add the sign_in behavior just add this to the test_helper.rb

  def sign_in_as(user)
    @controller.current_user = user
    return user
  end
Joshua