This project is archived and is in readonly mode.
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
-
CancelProfileIsBroken September 25th, 2009 @ 12:53 PM
- Tag changed from cookies, integration_test to bugmash, cookies, integration_test
-
John Pignata September 26th, 2009 @ 03:58 AM
-1 - cannot verify this bug. Trying to verify with the following test:
class CookieTest < ActionController::IntegrationTest def setup @cookie_data = { :remember_me => '1;abcdefg' } cookies.merge!(@cookie_data) end test "cookie escaping" do p cookies assert_equal(@cookie_data, cookies) end end
-
Elomar França September 26th, 2009 @ 03:12 PM
This bug cannot be verified on 2-3-stable, only on master, but I am almost sure it's a bug from rack-test 0.5.0 as 2-3-stable doesn't use it.
In Integration::Session, the method "cookies" returns the cookie_jar from an instance of Rack::Test::Session, defined on rack-test.
-
John Pignata September 26th, 2009 @ 09:50 PM
Elomar is correct - I can replicate on master.
The following code is in rack-test/rack/test/cookie_jar.rb:
def []=(name, value) # TODO: needs proper escaping merge("#{name}=#{value}") end
This ticket can be closed.
-
CancelProfileIsBroken September 27th, 2009 @ 11:51 AM
- Tag changed from bugmash, cookies, integration_test to cookies, integration_test
- State changed from new to invalid
Filed under "not our problem".
-
Matías Flores September 27th, 2009 @ 07:03 PM
- Tag changed from cookies, integration_test to cookies, integration_test
not reproducible on 2-3-stable. Elomar is right.
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>