Skip to content
This repository
Browse code

Ensure cookie keys are strings

  • Loading branch information...
commit 0a9270417c8eb03891ec161622bcf81e5cb8af02 1 parent 523c7c2
Andrew White pixeltrix authored
5 actionpack/lib/action_dispatch/middleware/cookies.rb
... ... @@ -1,4 +1,5 @@
1   -require "active_support/core_ext/object/blank"
  1 +require 'active_support/core_ext/object/blank'
  2 +require 'active_support/core_ext/hash/keys'
2 3
3 4 module ActionDispatch
4 5 class Request
@@ -129,7 +130,7 @@ def [](name)
129 130 end
130 131
131 132 def update(other_hash)
132   - @cookies.update other_hash
  133 + @cookies.update other_hash.stringify_keys
133 134 self
134 135 end
135 136
9 actionpack/test/dispatch/test_request_test.rb
@@ -39,6 +39,15 @@ class TestRequestTest < ActiveSupport::TestCase
39 39
40 40 req.cookie_jar["login"] = "XJ-122"
41 41 assert_cookies({"user_name" => "david", "login" => "XJ-122"}, req.cookie_jar)
  42 +
  43 + req.cookie_jar.delete(:login)
  44 + assert_cookies({"user_name" => "david"}, req.cookie_jar)
  45 +
  46 + req.cookie_jar.clear
  47 + assert_cookies({}, req.cookie_jar)
  48 +
  49 + req.cookie_jar.update(:user_name => "david")
  50 + assert_cookies({"user_name" => "david"}, req.cookie_jar)
42 51 end
43 52
44 53 private

0 comments on commit 0a92704

Please sign in to comment.
Something went wrong with that request. Please try again.