mirror of
https://github.com/github/rails.git
synced 2026-02-14 08:04:59 -05:00
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
38 lines
942 B
Ruby
38 lines
942 B
Ruby
require File.dirname(__FILE__) + '/../abstract_unit'
|
|
|
|
class CookieTest < Test::Unit::TestCase
|
|
class TestController < ActionController::Base
|
|
def authenticate
|
|
cookie "name" => "user_name", "value" => "david"
|
|
render_text "hello world"
|
|
end
|
|
|
|
def access_frozen_cookies
|
|
@cookies["wont"] = "work"
|
|
end
|
|
|
|
def rescue_action(e) raise end
|
|
end
|
|
|
|
def setup
|
|
@request = ActionController::TestRequest.new
|
|
@response = ActionController::TestResponse.new
|
|
|
|
@request.host = "www.nextangle.com"
|
|
end
|
|
|
|
def test_setting_cookie
|
|
@request.action = "authenticate"
|
|
assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david") ], process_request.headers["cookie"]
|
|
end
|
|
|
|
def test_setting_cookie
|
|
@request.action = "access_frozen_cookies"
|
|
assert_raises(TypeError) { process_request }
|
|
end
|
|
|
|
private
|
|
def process_request
|
|
TestController.process(@request, @response)
|
|
end
|
|
end |