1
我正在測試我的儀表板控制器,它需要用戶登錄才能訪問。下面是我的代碼如何用Authlogic以編程方式登錄用戶?
需要 'test_helper'
class DashboardControllerTest < ActionController::TestCase
test "should redirect if not logged in" do
get :index
assert_response 302
end
test "should get index if logged in" do
user = User.create(:username => "trivektor", :password => "abcd", :email => "[email protected]", :first_name => "Tri", :last_name => "Vuong", :active => true)
user_session = UserSession.create(:email => "[email protected]", :password => "abcd")
# get :index
# assert_response 200
end
end
不過,我總是得到這個錯誤
Authlogic ::會議::激活:: NotActivatedError:必須激活Authlogic ::會議: :在創建對象之前帶有控制器對象的Base.controller
請幫忙。謝謝。
感謝線索 – 2011-03-31 01:17:36