aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-09-22 09:01:33 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-09-22 09:01:33 +0000
commit28f7de07cbcbce04c848cc5c9a57abf0ab8227d2 (patch)
treee52c7709f6ceb5b7f37cd2e32e6d59f863b14cdd /actionpack
parentd1808916ae5127c3218468eb5ccb0bdfd7dc17d5 (diff)
downloadrails-28f7de07cbcbce04c848cc5c9a57abf0ab8227d2.tar.gz
rails-28f7de07cbcbce04c848cc5c9a57abf0ab8227d2.tar.bz2
rails-28f7de07cbcbce04c848cc5c9a57abf0ab8227d2.zip
Test CGI::Cookie#to_s. Closes #9624 [tarmo]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7535 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/controller/cookie_test.rb27
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