Ticket #3685: delete_cookies_with_options.2.diff
| File delete_cookies_with_options.2.diff, 1.7 kB (added by josh, 1 year ago) |
|---|
-
actionpack/test/controller/cookie_test.rb
old new 31 31 cookies.delete("user_name") 32 32 end 33 33 34 def delete_cookie_with_path 35 cookies.delete("user_name", :path => '/beaten') 36 render_text "hello world" 37 end 38 34 39 def rescue_action(e) 35 40 raise unless ActionController::MissingTemplate # No templates here, and we don't care about the output 36 41 end … … 85 90 assert_equal "david", jar["user_name"] 86 91 assert_equal nil, jar["something_else"] 87 92 end 93 94 def test_delete_cookie_with_path 95 get :delete_cookie_with_path 96 assert_equal "/beaten", @response.headers["cookie"].first.path 97 assert_not_equal "/", @response.headers["cookie"].first.path 98 end 88 99 end -
actionpack/lib/action_controller/cookies.rb
old new 62 62 end 63 63 64 64 # Removes the cookie on the client machine by setting the value to an empty string 65 # and setting its expiration date into the past 66 def delete(name) 67 set_cookie("name" => name.to_s, "value" => "", "expires" => Time.at(0)) 65 # and setting its expiration date into the past. Like []=, you can pass in an options 66 # hash to delete cookies with extra data such as a +path+. 67 def delete(name, options = {}) 68 options.stringify_keys! 69 set_cookie(options.merge("name" => name.to_s, "value" => "", "expires" => Time.at(0))) 68 70 end 69 71 70 72 private