aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2011-05-19 07:34:52 -0700
committerJoshua Peek <josh@joshpeek.com>2011-05-19 07:34:52 -0700
commit4cf4c7f4543f31d88793a4c9ead30161b7263bf2 (patch)
tree2f4a92ec8495def0d2082df96beff8a97ef38d0e
parent95bd19911a62fe7dbe8e72c08e29902efdcfce85 (diff)
parent2d50887b2437aaee2b051b06367bedfb9949eedf (diff)
downloadrails-4cf4c7f4543f31d88793a4c9ead30161b7263bf2.tar.gz
rails-4cf4c7f4543f31d88793a4c9ead30161b7263bf2.tar.bz2
rails-4cf4c7f4543f31d88793a4c9ead30161b7263bf2.zip
Merge pull request #1150 from stevenbristol/master
The cookie jar does not to_s cookie names (keys)
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb6
-rw-r--r--actionpack/test/dispatch/cookies_test.rb12
2 files changed, 11 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 24ebb8fed7..0057f64dd3 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -167,8 +167,8 @@ module ActionDispatch
handle_options(options)
- @set_cookies[key] = options
- @delete_cookies.delete(key)
+ @set_cookies[key.to_s] = options
+ @delete_cookies.delete(key.to_s)
value
end
@@ -181,7 +181,7 @@ module ActionDispatch
handle_options(options)
value = @cookies.delete(key.to_s)
- @delete_cookies[key] = options
+ @delete_cookies[key.to_s] = options
value
end
diff --git a/actionpack/test/dispatch/cookies_test.rb b/actionpack/test/dispatch/cookies_test.rb
index ebc16694db..e42c39f527 100644
--- a/actionpack/test/dispatch/cookies_test.rb
+++ b/actionpack/test/dispatch/cookies_test.rb
@@ -121,7 +121,7 @@ class CookiesTest < ActionController::TestCase
end
def string_key
- cookies['user_name'] = "david"
+ cookies['user_name'] = "dhh"
head :ok
end
@@ -417,14 +417,18 @@ class CookiesTest < ActionController::TestCase
assert_cookie_header "user_name=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"
end
+
def test_cookies_hash_is_indifferent_access
- [:symbol_key, :string_key].each do |cookie_key|
- get cookie_key
+ get :symbol_key
assert_equal "david", cookies[:user_name]
assert_equal "david", cookies['user_name']
- end
+ get :string_key
+ assert_equal "dhh", cookies[:user_name]
+ assert_equal "dhh", cookies['user_name']
end
+
+
def test_setting_request_cookies_is_indifferent_access
@request.cookies.clear
@request.cookies[:user_name] = "andrew"