Skip to content
Browse files

Add has_key? and key? methods to CookieJar removed in 0ca69ca

  • Loading branch information...
1 parent d1b6188 commit f34f0b7e0832a1910ab9c71080e024c8e36504b2 @josevalim josevalim committed
Showing with 14 additions and 0 deletions.
  1. +5 −0 actionpack/lib/action_dispatch/middleware/cookies.rb
  2. +9 −0 actionpack/test/dispatch/cookies_test.rb
View
5 actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -129,6 +129,11 @@ def [](name)
@cookies[name.to_s]
end
+ def key?(name)
+ @cookies.key?(name.to_s)
+ end
+ alias :has_key? :key?
+
def update(other_hash)
@cookies.update other_hash.stringify_keys
self
View
9 actionpack/test/dispatch/cookies_test.rb
@@ -148,6 +148,15 @@ def setup
@request.host = "www.nextangle.com"
end
+ def test_key_methods
+ assert !request.cookie_jar.key?(:foo)
+ assert !request.cookie_jar.has_key?("foo")
+
+ request.cookie_jar[:foo] = :bar
+ assert request.cookie_jar.key?(:foo)
+ assert request.cookie_jar.has_key?("foo")
+ end
+
def test_setting_cookie
get :authenticate
assert_cookie_header "user_name=david; path=/"

0 comments on commit f34f0b7

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