diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-04-05 17:01:33 -0500 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-04-05 15:22:09 -0700 |
commit | 570c54c39acc702eefcee9589ebe02d85173a1c1 (patch) | |
tree | cc0a9c87190767fe31520115830490ce073aa6f0 /actionpack/test | |
parent | d270da569efeabd7cd563028816452236713aa9f (diff) | |
download | rails-570c54c39acc702eefcee9589ebe02d85173a1c1.tar.gz rails-570c54c39acc702eefcee9589ebe02d85173a1c1.tar.bz2 rails-570c54c39acc702eefcee9589ebe02d85173a1c1.zip |
Fix cookie access in integration tests with other host names
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/integration_test.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index 14c0c3708b..20dc96d38d 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -245,6 +245,15 @@ class IntegrationProcessTest < ActionController::IntegrationTest render :text => "Gone", :status => 410 end + def set_cookie + cookies["foo"] = 'bar' + head :ok + end + + def get_cookie + render :text => cookies["foo"] + end + def redirect redirect_to :action => "get" end @@ -292,6 +301,42 @@ class IntegrationProcessTest < ActionController::IntegrationTest end end + test 'cookie persist to next request' do + with_test_route_set do + get '/set_cookie' + assert_response :success + + assert_equal "foo=bar; path=/", headers["Set-Cookie"] + assert_equal({"foo"=>"bar"}, cookies.to_hash) + + get '/get_cookie' + assert_response :success + assert_equal "bar", body + + assert_equal nil, headers["Set-Cookie"] + assert_equal({"foo"=>"bar"}, cookies.to_hash) + end + end + + test 'cookie persist to next request on another domain' do + with_test_route_set do + host! "37s.backpack.test" + + get '/set_cookie' + assert_response :success + + assert_equal "foo=bar; path=/", headers["Set-Cookie"] + assert_equal({"foo"=>"bar"}, cookies.to_hash) + + get '/get_cookie' + assert_response :success + assert_equal "bar", body + + assert_equal nil, headers["Set-Cookie"] + assert_equal({"foo"=>"bar"}, cookies.to_hash) + end + end + def test_redirect with_test_route_set do get '/redirect' |