#76 ✓resolved
John Pignata

rack-test cookie_jar doesn't escape properly

Reported by John Pignata | September 26th, 2009 @ 09:20 PM

Opening this to close out Rails LH https://rails.lighthouseapp.com/projects/8994/tickets/3047-problem-... -- from the original ticket:

Cookie escaping is not working out of the box with integration tests. Here is the problem in more understandable ruby form - since I am bad at explaining:

class CookieTest < ActionController::IntegrationTest
  def setup
    ...
    cookies[:remember_me] = "1;abcdefg"
    p cookies  # => {:remember_me=>"1;abcdefg"} 
  end

  test "cookie escaping" do
    visit '/'
    p cookies  # => {"abcdefg"=>nil, "remember_me"=>"1"} 
  end
end

I can solve the problem by:

class CookieTest < ActionController::IntegrationTest
  def setup
    ...
    cookies[:remember_me] = Rack::Utils.escape("1;abcdefg")
    p cookies  # => {:remember_me=>"1;abcdefg"}
  end

  test "cookie escaping" do
    visit '/'
    p cookies  # => {:remember_me=>"1;abcdefg"} 
  end
end

I think this should work without me explicitly calling Rack::Utils.escape on setip for the value I want to set on cookie.

Comments and changes to this ticket

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 ยป

People watching this ticket

Tags

Pages