#81 ✓resolved
Andrew Vit

Error destroying session with extra parameters in tests

Reported by Andrew Vit | April 5th, 2009 @ 08:13 AM

I'm running into this problem in my rSpec controller tests. I'm getting an ArgumentError internal to Authlogic when deleting cookies, as part of destroying a session:


UserSession.find.try(:destroy)

wrong number of arguments (2 for 1)
./vendor/plugins/authlogic/lib/authlogic/session/cookies.rb:123:in `delete'
./vendor/plugins/authlogic/lib/authlogic/session/cookies.rb:123:in `destroy_cookie'
./vendor/plugins/authlogic/lib/authlogic/session/callbacks.rb:71:in `after_destroy'
./vendor/plugins/authlogic/lib/authlogic/session/existence.rb:48:in `destroy'

I set a breakpoint in authlogic/session/cookies.rb:123 (in destroy_cookie method) to see what's going on:


   122            def destroy_cookie
   123              breakpoint
=> 124              controller.cookies.delete cookie_key, :domain => controller.cookie_domain
   125            end

(rdb:1) cookie_key
"user_credentials"

(rdb:1) controller.cookie_domain
nil

(rdb:1) controller.cookies
"{}"

(rdb:1) controller.cookies.class
Hash

(rdb:1) controller.cookies.delete cookie_key, :domain => controller.cookie_domain
ArgumentError Exception: wrong number of arguments (2 for 1)

Looks like cookies is a Hash here, not a ActionController::CookieJar (nor a Mock CookieJar) so the params don't fit the delete method from Hash.

Comments and changes to this ticket

  • Andrew Vit

    Andrew Vit April 5th, 2009 @ 08:41 AM

    I have a fix for this in my github fork, just changing one line in controller_adapter.rb to use MockCookieJar did the trick.

    Please pull from me or I can supply a patch. (I have another commit with a minor typo fix as well.)

    http://github.com/avit/authlogic...

  • Ben Johnson

    Ben Johnson April 5th, 2009 @ 11:11 AM

    • State changed from “new” to “resolved”

    Hey, sorry, I just saw the first message in my email and made the fix and pushed. Thanks a lot for letting me know about this.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.

People watching this ticket

Pages