aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/middleware/cookies.rb
diff options
context:
space:
mode:
authorPaul Annesley <paul@annesley.cc>2012-01-24 00:10:43 +1100
committerPaul Annesley <paul@annesley.cc>2012-01-24 00:31:22 +1100
commit5169543a6da2390191f780214e06c578eadb9442 (patch)
tree83eaaf97c6b729fcdb7a849c36a562c95fc23261 /actionpack/lib/action_dispatch/middleware/cookies.rb
parentec65f144633aaf6791e97173448123790e69ff21 (diff)
downloadrails-5169543a6da2390191f780214e06c578eadb9442.tar.gz
rails-5169543a6da2390191f780214e06c578eadb9442.tar.bz2
rails-5169543a6da2390191f780214e06c578eadb9442.zip
ActionDispatch::Cookies::CookieJar#deleted? predicate method.
Necessary in controller tests to determine if the CookieJar will delete the given cookie.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/cookies.rb')
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 39ff58a447..25f1db8228 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -191,6 +191,15 @@ module ActionDispatch
value
end
+ # Whether the given cookie is to be deleted by this CookieJar.
+ # Like <tt>[]=</tt>, you can pass in an options hash to test if a
+ # deletion applies to a specific <tt>:path</tt>, <tt>:domain</tt> etc.
+ def deleted?(key, options = {})
+ options.symbolize_keys!
+ handle_options(options)
+ @delete_cookies[key.to_s] == options
+ end
+
# Removes all cookies on the client machine by calling <tt>delete</tt> for each cookie
def clear(options = {})
@cookies.each_key{ |k| delete(k, options) }