This project is archived and is in readonly mode.

#4688 ✓stale
Elise Huard

2.3.8: problem with the cookie_jar in rack_test

Reported by Elise Huard | May 25th, 2010 @ 09:46 AM

I noticed this during tests with capybara and the new version of rails - all our logins failed.

The problem is due to the fact that rack-tests attempts to create a cookie even if the Set-Cookie header is blank.
The comparison

def replaces?(other)
  [name.downcase, domain, path] == [other.name.downcase, other.domain, other.path]
end

in lib/rack/test/cookie_jar.rb of rack-test then gives a whiny nil on the downcase, because the name is not set.

The application itself seems to work, so this only affects the tests.

Stack trace:
--> #0 Rack::Test::Cookie.replaces?(other#Rack::Test::Cookie)

   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test/cookie_jar.rb:30
[#1](/projects/8994/tickets/1 "Ticket #1") Array.<< 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test/cookie_jar.rb:131
[#2](/projects/8994/tickets/2 "Ticket #2") Rack::Test::CookieJar.<<(new_cookie#Rack::Test::Cookie) 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test/cookie_jar.rb:130
[#3](/projects/8994/tickets/3 "Ticket #3") Array.merge 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test/cookie_jar.rb:125
[#4](/projects/8994/tickets/4 "Ticket #4") Rack::Test::CookieJar.merge(raw_cookies#Array, uri#URI::Generic) 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test/cookie_jar.rb:123
[#5](/projects/8994/tickets/5 "Ticket #5") Rack::MockSession.request(uri#URI::Generic, env#Hash) 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/mock_session.rb:35
[#6](/projects/8994/tickets/6 "Ticket #6") Rack::Test::Session.process_request(uri#URI::Generic, env#Hash) 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test.rb:207
[#7](/projects/8994/tickets/7 "Ticket #7") Rack::Test::Session.post(uri#String, params#Hash, env#Hash) 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rack-test-0.5.3/lib/rack/test.rb:66
[#8](/projects/8994/tickets/8 "Ticket #8") Kernel.__send__(args#Array, block#NilClass) at line (__FORWARDABLE__):3
[#9](/projects/8994/tickets/9 "Ticket #9") Rack::Test::Methods.post at line (__FORWARDABLE__):3
[#10](/projects/8994/tickets/10 "Ticket #10") Capybara::Driver::RackTest.post 
   at line /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/capybara-0.3.8/lib/capybara/driver/rack_test_driver.rb:227
[#11](/projects/8994/tickets/11 "Ticket #11") Kernel.send(method#Symbol, path#String, attributes#Hash)

Comments and changes to this ticket

  • Elise Huard

    Elise Huard May 25th, 2010 @ 09:56 AM

    • Tag set to 2.3.8
  • Elise Huard
  • Etienne Vallette d'Osia

    Etienne Vallette d'Osia May 25th, 2010 @ 06:29 PM

    This is a quick and dirty fix which makes all my tests pass.
    I hope it can help until the real bug fix !

    --- lib/rack/test/cookie_jar.rb
    +++ lib/rack/test/cookie_jar.rb
    @@ -126,7 +126,6 @@
           end
     
           def <<(new_cookie)
    +        return if new_cookie.name.blank?
             @cookies.reject! do |existing_cookie|
               new_cookie.replaces?(existing_cookie)
             end
    
  • Anil Wadghule

    Anil Wadghule May 25th, 2010 @ 06:37 PM

    Etienne, can you provide patch file?

  • Etienne Vallette d'Osia

    Etienne Vallette d'Osia May 25th, 2010 @ 08:44 PM

    Just to be clear, I see this fix like an help for final users, waiting for real fix :-)

  • rbxbx
  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:52 PM

    • State changed from “new” to “open”
    • Tag changed from 2.3.8 to 238

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:52 PM

    • State changed from “open” to “stale”

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Tags

Pages