0
class TestController < ActionController::Base
0
def authenticate_with_deprecated_writer
0
cookie "name" => "user_name", "value" => "david"
0
- render_text "hello world"
0
cookies["user_name"] = "david"
0
- render_text "hello world"
0
def authenticate_for_fourten_days
0
cookies["user_name"] = { "value" => "david", "expires" => Time.local(2005, 10, 10) }
0
- render_text "hello world"
0
def authenticate_for_fourten_days_with_symbols
0
cookies[:user_name] = { :value => "david", :expires => Time.local(2005, 10, 10) }
0
- render_text "hello world"
0
def set_multiple_cookies
0
cookies["user_name"] = { "value" => "david", "expires" => Time.local(2005, 10, 10) }
0
cookies["login"] = "XJ-122"
0
- render_text "hello world"
0
def access_frozen_cookies
0
cookies["will"] = "work"
0
- render_text "hello world"
0
- def rescue_action(e) raise end
0
+ cookies.delete("user_name")
0
+ raise unless ActionController::MissingTemplate # No templates here, and we don't care about the output
0
@request = ActionController::TestRequest.new
0
@response = ActionController::TestResponse.new
0
+ @controller = TestController.new
0
@request.host = "www.nextangle.com"
0
def test_setting_cookie_with_deprecated_writer
0
- @request.action = "authenticate_with_deprecated_writer"
0
- assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david") ], process_request.headers["cookie"]
0
+ get :authenticate_with_deprecated_writer
0
+ assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david") ], @response.headers["cookie"]
0
def test_setting_cookie
0
- @request.action = "authenticate"
0
- assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david") ], process_request.headers["cookie"]
0
+ assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david") ], @response.headers["cookie"]
0
def test_setting_cookie_for_fourteen_days
0
- @request.action = "authenticate_for_fourten_days"
0
- assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], process_request.headers["cookie"]
0
+ get :authenticate_for_fourten_days
0
+ assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], @response.headers["cookie"]
0
def test_setting_cookie_for_fourteen_days_with_symbols
0
- @request.action = "authenticate_for_fourten_days"
0
- assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], process_request.headers["cookie"]
0
+ get :authenticate_for_fourten_days
0
+ assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "david", "expires" => Time.local(2005, 10, 10)) ], @response.headers["cookie"]
0
def test_multiple_cookies
0
- @request.action = "set_multiple_cookies"
0
- assert_equal 2, process_request.headers["cookie"].size
0
+ get :set_multiple_cookies
0
+ assert_equal 2, @response.cookies.size
0
def test_setting_test_cookie
0
- @request.action = "access_frozen_cookies"
0
- assert_nothing_raised { process_request }
0
+ assert_nothing_raised { get :access_frozen_cookies }
0
- TestController.process(@request, @response)
0
+ def test_expiring_cookie
0
+ assert_equal [ CGI::Cookie::new("name" => "user_name", "value" => "", "expires" => Time.at(0)) ], @response.headers["cookie"]
0
+ def test_cookiejar_accessor
0
+ @request.cookies["user_name"] = CGI::Cookie.new("name" => "user_name", "value" => "david", "expires" => Time.local(2025, 10, 10))
0
+ @controller.request = @request
0
+ jar = ActionController::CookieJar.new(@controller)
0
+ assert_equal "david", jar["user_name"]
0
+ assert_equal nil, jar["something_else"]
Comments
No one has commented yet.