6

In my system, users registering via rails website. I have to authenticate users from a custom application server written in ruby.

error messsage:

You must activate the Authlogic::Session::Base.controller with a controller object before creating objects (Authlogic::Session::Activation::NotActivatedError)
Prakash Murthy
  • 12,923
  • 3
  • 46
  • 74
airy
  • 571
  • 6
  • 8

3 Answers3

6

From: 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
jigfox
  • 18,057
  • 3
  • 60
  • 73
user239662
  • 61
  • 1
  • 2
5

Try this first:

Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
epid
  • 153
  • 5
0

I got around this error using advice from user239662's answer (it wasn't clear to me hence I'm posting this solution). My Cucumber step definition now looks like this:

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
RobinGower
  • 928
  • 6
  • 14