How to test AuthLogic authentication from the console?

556 views
Skip to first unread message

The Wildgoose

unread,
May 10, 2009, 11:46:31 AM5/10/09
to Authlogic
Hi, how should I "load" authlogic in order that I can test
authentication from the console?


>> us=UserSession.new()
Authlogic::Session::Activation::NotActivatedError: You must activate
the Authlogic::Session::Base.controller with a controller object
before creating objects
from /home/src/ruby/rails/blog_mailasail/vendor/plugins/authlogic/lib/
authlogic/session/activation.rb:47:in `initialize'
from /home/src/ruby/rails/blog_mailasail/vendor/plugins/authlogic/lib/
authlogic/session/klass.rb:61:in `initialize'
from /home/src/ruby/rails/blog_mailasail/vendor/plugins/authlogic/lib/
authlogic/session/scopes.rb:79:in `initialize'
from (irb):9:in `new'
from (irb):9


I can't see how to use "activate_authlogic" in this situation?

Thanks

Ed W

Ben Johnson

unread,
May 10, 2009, 12:08:44 PM5/10/09
to auth...@googlegroups.com
Right, just like AR needs a DB connection, Authlogic needs a
connection to a controller object. To use it in the console you need
to use a mock controller:

Authlogic::TestCase::MockController.new

hope that helps.



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

The Wildgoose

unread,
May 10, 2009, 2:30:33 PM5/10/09
to Authlogic


On May 10, 5:08 pm, Ben Johnson <bjohn...@binarylogic.com> wrote:
> Right, just like AR needs a DB connection, Authlogic needs a  
> connection to a controller object. To use it in the console you need  
> to use a mock controller:
>
> Authlogic::TestCase::MockController.new

Just to clarify the solution, I need

m=Authlogic::TestCase::MockController.new
UserSession.controller=m
us=UserSession.new()

Thanks Ben

Ben Johnson

unread,
May 10, 2009, 2:32:38 PM5/10/09
to auth...@googlegroups.com
Yes, authlogic needs to interact with a controller object, so you
basically need to trick it, since there is no controller in the console.



Ben Johnson
Binary Logic

W: www.binarylogic.com
E: bjoh...@binarylogic.com

1430 Broadway
7th Floor - NECO
New York, NY 10018

Reply all
Reply to author
Forward
0 new messages