我已为Active Admin中的某些资源定义了自己的控制器和member_actions,现在我不知道如何使用ActiveSupport :: TestCase对它们进行测试。
任何帮助都将不胜感激,谢谢。
答案 0 :(得分:1)
这样的事情:
(我正在使用mocha作为存根。如果不是,则需要找到另一种方式来存根身份验证,否则实际以管理员用户身份登录)
require 'test_helper'
class AdminUserControllerTest < ActionController::TestCase
setup do
# Creates a reference to the admin controller
@controller = ::Admin::UsersController.new
# Prevents checking for a valid user session (pretends we're logged in)
@controller.stubs(:authenticate_active_admin_user)
end
test "should ..." do
# ... the test ...
end
end