Permalink
Browse files

write_cookies! in ActionDispatch::TestRequest won't write nil value w…

…hen == 'u' on 1.8.7
  • Loading branch information...
1 parent 0820283 commit 36836f1add1aa7d9fb407c16012dc772531a8277 @bfolkens bfolkens committed Jul 14, 2011
@@ -83,7 +83,7 @@ def write_cookies!
end
def escape_cookie(name, value)
- "#{Rack::Utils.escape(name)}=#{Rack::Utils.escape(value)}"
+ "#{Rack::Utils.escape(name)}=#{Rack::Utils.escape(value.to_s)}"
end
def delete_nil_values!
@@ -41,5 +41,11 @@ class TestRequestTest < ActiveSupport::TestCase
req.cookies["login"] = "XJ-122"
assert_equal({"user_name" => "david", "login" => "XJ-122"}, req.cookies)
assert_equal %w(login=XJ-122 user_name=david), req.env["HTTP_COOKIE"].split(/; /).sort
- end
+
+ assert_nothing_raised do
+ req.cookies["login"] = nil
+ assert_equal({"user_name" => "david", "login" => nil}, req.cookies)
+ assert_equal %w(login= user_name=david), req.env["HTTP_COOKIE"].split(/; /).sort
+ end
+ end
end

0 comments on commit 36836f1

Please sign in to comment.