Problem with Authlogic and Unit/Functional Tests in Rails

陌路散爱 提交于 2019-12-04 19:41:48

Put the setup :activate_authlogic class in your unit test class and not in the ActiveSupport::TestCase declaration in test_helper.

e.g.

class ExampleControllerTest < ActionController::TestCase
    setup :activate_authlogic
end

I had to include the Authlogic test case module like this in order to get things working.

class ExampleControllerTest < ActionController::TestCase
    include Authlogic::TestCase
    setup :activate_authlogic
end

I'm not sure why Authlogic wouldn't include itself on my system... but the code (in authlogic/test_case) doesn't work on my system:

::Test::Unit::TestCase.send(:include, TestCase) if defined?(::Test::Unit::TestCase)

http://rdoc.info/github/binarylogic/authlogic/master/Authlogic/TestCase
evertything is very well described on the link above.

The setup :authlogic line needs to be in the ActionController::TestCase class, not the ActiveSupport::TestCase.

Inside your test_helper, put this in:

  class ActionController::TestCase
    setup :activate_authlogic
  end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!