TestRequest lacks a params property

20 views
Skip to first unread message

Antonio Salazar Cardozo

unread,
May 6, 2009, 2:23:20 PM5/6/09
to Authlogic
Hey everyone,
Trying to integrate Authlogic into our existing app, and some of our
specs are failing with:

undefined method `params' for #<ActionController::TestRequest:
0x31d7f88>

A little investigating tells me that the Authlogic `controller'
variable is being set to the TestRequest object by activate_authlogic.
However, TestRequest doesn't seem to have a params property in Rails
2.2 (it inherits from AbstractRequest, which has no params property,
instead of Rack::Request as it does in Rails 2.3). Am I right in this
observation, or does the problem lie elsewhere?
Thanks,
Antonio

Ben Johnson

unread,
May 6, 2009, 2:25:07 PM5/6/09
to auth...@googlegroups.com
Can you give me the backtrace?



Ben Johnson
Binary Logic

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

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

Antonio Salazar Cardozo

unread,
May 6, 2009, 2:30:43 PM5/6/09
to Authlogic
This happens when attempting to create a new user using FactoryGirl,
and before the session is created. Here's the whole failure:

4)
NoMethodError in 'UserSessionsController when showing session data as
JSON should return the UserSession converted to JSON'
undefined method `params' for #<ActionController::TestRequest:
0x3137dd0>
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/
controller_adapters/abstract_adapter.rb:30:in `params'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/
params.rb:95:in `params_credentials'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/
params.rb:71:in `params_enabled?'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/
params.rb:65:in `persist_by_params'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:93:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:92:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:92:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:92:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:277:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/
callbacks.rb:78:in `persist'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/
persistence.rb:55:in `persisting?'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/session/
persistence.rb:39:in `find'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/
acts_as_authentic/session_maintenance.rb:96:in
`get_session_information'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/
acts_as_authentic/session_maintenance.rb:95:in `each'
/Library/Ruby/Gems/1.8/gems/authlogic-2.0.11/lib/authlogic/
acts_as_authentic/session_maintenance.rb:95:in
`get_session_information'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:93:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:92:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:92:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:92:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/
callbacks.rb:277:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
callbacks.rb:315:in `callback'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
callbacks.rb:221:in `create_or_update'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
base.rb:2400:in `save_without_validation!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
validations.rb:1019:in `save_without_dirty!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
dirty.rb:87:in `save_without_transactions!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
transactions.rb:150:in `save_without_after_commit_callback!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/database_statements.rb:66:in
`transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
transactions.rb:129:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
transactions.rb:138:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
transactions.rb:150:in `save_without_after_commit_callback!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
transactions.rb:158:in `rollback_active_record_state!'
/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/
transactions.rb:150:in `save_without_after_commit_callback!'
/Users/Shadowfiend/openstudy/rails/vendor/plugins/thinking-sphinx/lib/
thinking_sphinx/active_record/delta.rb:42:in `save!'
/Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/
factory_girl/proxy/create.rb:5:in `result'
/Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/
factory_girl/factory.rb:293:in `run'
/Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.1/lib/
factory_girl/factory.rb:237:in `create'
./spec/controllers/user_sessions_controller_spec.rb:36:


On May 6, 2:25 pm, Ben Johnson <bjohn...@binarylogic.com> wrote:
> Can you give me the backtrace?
>
> Ben Johnson
> Binary Logic
>
> W:www.binarylogic.com
> E: bjohn...@binarylogic.com

Antonio Salazar Cardozo

unread,
May 6, 2009, 2:35:54 PM5/6/09
to Authlogic
Ew, that looks awful, sorry. Gitsified: http://gist.github.com/107657

On May 6, 2:30 pm, Antonio Salazar Cardozo <savedfastc...@gmail.com>
wrote:

Mark Mansour

unread,
May 10, 2009, 11:36:37 PM5/10/09
to Authlogic
Antonio, did you manage to resolve this?

I've got the same issue.

Mark

On May 7, 4:35 am, Antonio Salazar Cardozo <savedfastc...@gmail.com>
wrote:
> Ew, that looks awful, sorry. Gitsified:http://gist.github.com/107657
>
> On May 6, 2:30 pm, Antonio  Salazar Cardozo <savedfastc...@gmail.com>
> wrote:
>
> > This happens when attempting to create a new user using FactoryGirl,
> > and before the session is created. Here's the whole failure:
>
> > 4)
> > NoMethodError in 'UserSessionsController when showing session data as
> > JSON should return the UserSession converted to JSON'
> >undefinedmethod`params' for #<ActionController::TestRequest:
> > > >undefinedmethod`params' for #<ActionController::TestRequest:
> > > > 0x31d7f88>
>
> > > > A little investigating tells me that the Authlogic `controller'
> > > > variable is being set to the TestRequest object by activate_authlogic.
> > > > However, TestRequest doesn't seem to have aparamsproperty in Rails

Antonio Salazar Cardozo

unread,
May 11, 2009, 1:43:04 AM5/11/09
to auth...@googlegroups.com
I monkey-patched things a little when dealing with a non-existent params method to alias it to the parameters method that TestRequest DOES have pre-2.3. The relevant code is available on github on my fork: github.com/Shadowfiend/authlogic/tree/master

That said, I consider this to be a hack solution and suspect that a better solution would be some sort of subclass or adapter or some such that is provided instead of the TestRequest object in these cases.

Also worth noting is that just today I shifted our app to 2.3, so this should no longer be a problem for me. Nonetheless, I made sure that all of our specs passed with the aforementioned solution before I decided to move to 2.3. So, no guarantees, but it is probably a valid fix.
Antonio

On May 10, 2009, at 23:36 , Mark Mansour wrote:


Antonio, did you manage to resolve this?

I've got the same issue.

Mark
[Elided...]

jeff_wigal

unread,
May 11, 2009, 4:22:49 PM5/11/09
to Authlogic
I'm working on something similar here:

http://binarylogic.lighthouseapp.com/projects/18752-authlogic/tickets/98-cant-get-testcase-to-work

On May 11, 1:43 am, Antonio Salazar Cardozo <savedfastc...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages