From 28f7de07cbcbce04c848cc5c9a57abf0ab8227d2 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 22 Sep 2007 09:01:33 +0000 Subject: Test CGI::Cookie#to_s. Closes #9624 [tarmo] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7535 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/test/controller/cookie_test.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'actionpack') 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 -- cgit v1.2.3