在我的系统中,用户通过rails网站注册。我必须使用ruby编写的自定义应用程序服务器对用户进行身份验证。
错误消息:
You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError)
答案 0 :(得分:6)
来自:http://rdoc.info/projects/binarylogic/authlogic
require "authlogic/test_case" # include at the top of test_helper.rb
setup :activate_authlogic # run before tests are executed
UserSession.create(users(:whomever)) # logs a user in
答案 1 :(得分:5)
首先尝试:
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
答案 2 :(得分:0)
我使用来自user239662答案的建议解决了这个错误(我不清楚,因此我发布了这个解决方案)。我的Cucumber步骤定义现在看起来像这样:
When /^I am logged in as "(.*)"$/ do |user|
@current_user = User.make!(:username => user)
require 'authlogic/test_case'
activate_authlogic
@current_session = UserSession.create!(@current_user)
end