Ticket #5924: cookies_symbols_and_strings_are_synonymous.diff
| File cookies_symbols_and_strings_are_synonymous.diff, 1.5 kB (added by sandofsky, 2 years ago) |
|---|
-
test/controller/cookie_test.rb
old new 59 59 assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], @response.headers["cookie"] 60 60 end 61 61 62 def test_cookie_keys_are_synonymous_as_strings_or_symbols 63 get :authenticate_for_fourten_days 64 assert_equal @response.cookies["user_name"], @response.cookies[:user_name] 65 end 66 62 67 def test_setting_cookie_for_fourteen_days_with_symbols 63 68 get :authenticate_for_fourten_days 64 69 assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], @response.headers["cookie"] -
lib/action_controller/test_process.rb
old new 252 252 # 253 253 # assert_equal ['AuthorOfNewPage'], r.cookies['author'].value 254 254 def cookies 255 headers['cookie'].inject({}) { |hash, cookie| hash[cookie.name] = cookie; hash } 255 cookie_hash = Hash.new { |hash, key| key.kind_of?(Symbol) ? hash[key.to_s] : nil } 256 headers['cookie'].inject(cookie_hash) { |hash, cookie| hash[cookie.name] = cookie; hash } 256 257 end 257 258 258 259 # Returns binary content (downloadable file), converted to a String