문제

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?

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top