Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7979

Show
Ignore:
Timestamp:
10/20/07 17:35:12 (1 year ago)
Author:
rick
Message:

merge [7978] from edge

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/actionpack/CHANGELOG

    r7844 r7979  
     1* Ensure that cookies handle array values correctly.  Closes #9937 [queso] 
     2 
    13*1.13.5* (October 12th, 2007) 
    24 
  • branches/1-2-stable/actionpack/lib/action_controller/cookies.rb

    r7161 r7979  
    4848    # or cookies[]= (for simple name/value cookies without options). 
    4949    def [](name) 
    50       @cookies[name.to_s].value.first if @cookies[name.to_s] && @cookies[name.to_s].respond_to?(:value) 
     50      cookie = @cookies[name.to_s] 
     51      if cookie && cookie.respond_to?(:value) 
     52        cookie.size > 1 ? cookie.value : cookie.value.to_s 
     53      end  
    5154    end 
    5255 
  • branches/1-2-stable/actionpack/test/controller/cookie_test.rb

    r7161 r7979  
    2323      cookies["login"]     = "XJ-122" 
    2424    end 
    25  
     25     
    2626    def access_frozen_cookies 
    2727      cookies["will"] = "work" 
     
    9292  end 
    9393 
     94  def test_cookiejar_accessor_with_array_value 
     95    a = %w{1 2 3} 
     96    @request.cookies["pages"] = CGI::Cookie.new("name" => "pages", "value" => a, "expires" => Time.local(2025, 10, 10)) 
     97    @controller.request = @request 
     98    jar = ActionController::CookieJar.new(@controller) 
     99    assert_equal a, jar["pages"] 
     100  end 
     101   
    94102  def test_delete_cookie_with_path 
    95103    get :delete_cookie_with_path