diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/test/controller/cookie_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb index f3366619dd..6a88517582 100644 --- a/actionpack/test/controller/cookie_test.rb +++ b/actionpack/test/controller/cookie_test.rb @@ -97,4 +97,31 @@ class CookieTest < Test::Unit::TestCase assert_equal "/beaten", @response.headers["cookie"].first.path assert_not_equal "/", @response.headers["cookie"].first.path end + + def test_cookie_to_s_simple_values + assert_equal 'myname=myvalue; path=', CGI::Cookie.new('myname', 'myvalue').to_s + end + + def test_cookie_to_s_hash + cookie_str = CGI::Cookie.new( + 'name' => 'myname', + 'value' => 'myvalue', + 'domain' => 'mydomain', + 'path' => 'mypath', + 'expires' => Time.utc(2007, 10, 20), + 'secure' => true, + 'http_only' => true).to_s + assert_equal 'myname=myvalue; domain=mydomain; path=mypath; expires=Sat, 20 Oct 2007 00:00:00 GMT; secure; HttpOnly', cookie_str + end + + def test_cookie_to_s_hash_default_not_secure_not_http_only + cookie_str = CGI::Cookie.new( + 'name' => 'myname', + 'value' => 'myvalue', + 'domain' => 'mydomain', + 'path' => 'mypath', + 'expires' => Time.utc(2007, 10, 20)) + assert cookie_str !~ /secure/ + assert cookie_str !~ /HttpOnly/ + end end |