0

我正在使用Clearance对我的 rails 应用程序进行身份验证,该应用程序有效。但是现在我所有的单元测试都失败了,因为它们重定向到登录页面,这是有道理的。Clearance 似乎具有修复该问题的辅助功能,但我只能为Shoulda找到它们。Test::Unit 是否有等效的助手?

4

1 回答 1

2

我认为 shoulda 宏的工作方式会有更多的“魔力”,但它实际上非常简单。要添加登录行为,只需将其添加到 test_helper.rb

  def sign_in_as(user)
    @controller.current_user = user
    return user
  end
于 2010-06-11T14:53:20.050 回答