public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
merge [7978] from edge

git-svn-id: 
http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7979 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
technoweenie (author)
Sat Oct 20 10:35:12 -0700 2007
commit  5285270dde50cd83239b70a23139319dd8d9e302
tree    9b130e5fa6284ffd2e4dcb81a994279a72377619
parent  257d8605c9bd8926fbc1c5ea15da5d7abcd1bc78
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+* Ensure that cookies handle array values correctly. Closes #9937 [queso]
0
+
0
 *1.13.5* (October 12th, 2007)
0
 
0
 * Backport: allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan, Diego Algorta Casamayou]
...
47
48
49
50
 
 
 
 
51
52
53
...
47
48
49
 
50
51
52
53
54
55
56
0
@@ -47,7 +47,10 @@ module ActionController #:nodoc:
0
     # Returns the value of the cookie by +name+ -- or nil if no such cookie exists. You set new cookies using either the cookie method
0
     # or cookies[]= (for simple name/value cookies without options).
0
     def [](name)
0
- @cookies[name.to_s].value.first if @cookies[name.to_s] && @cookies[name.to_s].respond_to?(:value)
0
+ cookie = @cookies[name.to_s]
0
+ if cookie && cookie.respond_to?(:value)
0
+ cookie.size > 1 ? cookie.value : cookie.value.to_s
0
+ end
0
     end
0
 
0
     def []=(name, options)
...
22
23
24
25
 
26
27
28
...
91
92
93
 
 
 
 
 
 
 
 
94
95
96
...
22
23
24
 
25
26
27
28
...
91
92
93
94
95
96
97
98
99
100
101
102
103
104
0
@@ -22,7 +22,7 @@ class CookieTest < Test::Unit::TestCase
0
       cookies["user_name"] = { "value" => "david", "expires" => Time.local(2005, 10, 10) }
0
       cookies["login"] = "XJ-122"
0
     end
0
-
0
+
0
     def access_frozen_cookies
0
       cookies["will"] = "work"
0
     end
0
@@ -91,6 +91,14 @@ class CookieTest < Test::Unit::TestCase
0
     assert_equal nil, jar["something_else"]
0
   end
0
 
0
+ def test_cookiejar_accessor_with_array_value
0
+ a = %w{1 2 3}
0
+ @request.cookies["pages"] = CGI::Cookie.new("name" => "pages", "value" => a, "expires" => Time.local(2025, 10, 10))
0
+ @controller.request = @request
0
+ jar = ActionController::CookieJar.new(@controller)
0
+ assert_equal a, jar["pages"]
0
+ end
0
+
0
   def test_delete_cookie_with_path
0
     get :delete_cookie_with_path
0
     assert_equal "/beaten", @response.headers["cookie"].first.path

Comments

    No one has commented yet.