This project is archived and is in readonly mode.

#3047 ✓invalid
Marko Seppä

problem with cookie escaping on integration tests

Reported by Marko Seppä | August 13th, 2009 @ 10:44 AM

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

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>

Pages