Ticket #3685: delete_cookies_with_options.diff
| File delete_cookies_with_options.diff, 1.7 kB (added by Chris Wanstrath, 2 years ago) |
|---|
-
actionpack/test/controller/cookie_test.rb
old new 33 33 render_text "hello world" 34 34 end 35 35 36 def delete_cookie_with_path 37 cookies.delete("user_name", :path => '/beaten') 38 render_text "hello world" 39 end 40 36 41 def rescue_action(e) raise end 37 42 end 38 43 … … 73 78 assert_nothing_raised { process_request } 74 79 end 75 80 81 def test_delete_cookie_with_path 82 @request.action = "delete_cookie_with_path" 83 assert_equal "/beaten", process_request.headers["cookie"].first.path 84 assert_not_equal "/", process_request.headers["cookie"].first.path 85 end 86 76 87 private 77 88 def process_request 78 89 TestController.process(@request, @response) -
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