开发者

Clearance with Test::Unit

开发者 https://www.devze.com 2023-01-02 20:04 出处:网络
I am using Clearance for authentication with 开发者_C百科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 he

I am using Clearance for authentication with 开发者_C百科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
0

精彩评论

暂无评论...
验证码 换一张
取 消