Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CookieJar#delete should return the key's value, consistent with a Hash

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit a8dc9fd27b845193fd209a249e084f993a10c19d 1 parent ff8be66
@packagethief packagethief authored jeremy committed
View
3  actionpack/lib/action_controller/metal/cookies.rb
@@ -87,8 +87,9 @@ def []=(key, options)
def delete(key, options = {})
options.symbolize_keys!
options[:path] = "/" unless options.has_key?(:path)
- super(key.to_s)
+ value = super(key.to_s)
@controller.response.delete_cookie(key, options)
+ value
end
end
end
View
7 actionpack/test/controller/cookie_test.rb
@@ -118,6 +118,13 @@ def test_cookiejar_accessor_with_array_value
assert_equal %w{1 2 3}, jar["pages"]
end
+ def test_cookiejar_delete_removes_item_and_returns_its_value
+ @request.cookies["user_name"] = "david"
+ @controller.response = @response
+ jar = ActionController::CookieJar.new(@controller)
+ assert_equal "david", jar.delete("user_name")
+ end
+
def test_delete_cookie_with_path
get :delete_cookie_with_path
assert_cookie_header "user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"
View
4 actionpack/test/dispatch/session/test_session_test.rb
@@ -26,11 +26,11 @@ def test_setting_session_item_sets_item
assert_equal('value', session[:key])
end
- def test_calling_delete_removes_item
+ def test_calling_delete_removes_item_and_returns_its_value
session = ActionController::TestSession.new
session[:key] = 'value'
assert_equal('value', session[:key])
- session.delete(:key)
+ assert_equal('value', session.delete(:key))
assert_nil(session[:key])
end
Please sign in to comment.
Something went wrong with that request. Please try again.