Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

reset_session in action_dispatch/http/request.rb failing in test mode

#5634

I get the below when running one of my tests that does a reset_session in a ActionController::TestCase

NoMethodError: undefined method `destroy' for #<Hash:0xc672d3c>
actionpack (3.0.0) lib/action_dispatch/http/request.rb:202:in `reset_session'
actionpack (3.0.0) lib/action_controller/metal/rack_delegation.rb:23:in `reset_session'

The following seems to have fixed it for me:

def reset_session
  session.destroy if session && session.respond_to?(:destroy)
  self.session = {}
  @env['action_dispatch.request.flash_hash'] = nil
end

Reported by Jim Wilson · September 15th, 2010 @ 05:38 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Noah
    Noah

    This happens to me as well in a test that happens to call "reset_session" twice in a row. The first reset_session sets "session" to an empty hash, and the second call blows up because "destroy" is not defined on a hash.

    September 21st, 2010 @ 06:42 PM

  2. Franco Catena
    Franco Catena

    This problem was fixed in this commit: https://github.com/rails/rails/commit/653acac069e66f53b791caa4838a1..., I hope someone change the status to solved.

    November 3rd, 2010 @ 05:53 PM

  3. Neeraj Singh
    Neeraj Singh
    • State changed from new to resolved
    • Importance changed from to Low

    November 3rd, 2010 @ 06:08 PM