Changeset 21
- Timestamp:
- 11/26/04 02:09:38 (4 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/cookies.rb (modified) (3 diffs)
- trunk/actionpack/test/controller/cookie_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/cookies.rb
r20 r21 5 5 # 6 6 # cookies["user_name"] = "david" # => Will set a simple session cookie 7 # cookies["login"] = { "value" => "XJ-122", "expires"=> Time.now + 360} # => Will set a cookie that expires in 1 hour7 # cookies["login"] = { :value => "XJ-122", :expires => Time.now + 360} # => Will set a cookie that expires in 1 hour 8 8 # 9 9 # Examples for reading: … … 12 12 # cookies.size # => 2 13 13 # 14 # All the option s for setting cookies are:14 # All the option symbols for setting cookies are: 15 15 # 16 16 # value:: the cookie's value or list of values (as an array). … … 42 42 def []=(name, options) 43 43 if options.is_a?(Hash) 44 options.each { |key, value| options[key.to_s] = value } 44 45 options["name"] = name 45 46 else trunk/actionpack/test/controller/cookie_test.rb
r20 r21 15 15 def authenticate_for_fourten_days 16 16 cookies["user_name"] = { "value" => "david", "expires" => Time.local(2005, 10, 10) } 17 render_text "hello world" 18 end 19 20 def authenticate_for_fourten_days_with_symbols 21 cookies["user_name"] = { :value => "david", :expires => Time.local(2005, 10, 10) } 17 22 render_text "hello world" 18 23 end … … 53 58 end 54 59 60 def test_setting_cookie_for_fourteen_days_with_symbols 61 @request.action = "authenticate_for_fourten_days" 62 assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], process_request.headers["cookie"] 63 end 64 55 65 def test_multiple_cookies 56 66 @request.action = "set_multiple_cookies"