aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-16 17:21:46 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-16 17:22:27 -0600
commitd2d4acf02793580e0f0c1bc380389527325b6254 (patch)
treec7749a89bda18f9367a31048f5a2e217dd3eae25 /actionpack/test
parent8d87c80c19b7f0c0966fcfd52e7a6ed99d347a36 (diff)
downloadrails-d2d4acf02793580e0f0c1bc380389527325b6254.tar.gz
rails-d2d4acf02793580e0f0c1bc380389527325b6254.tar.bz2
rails-d2d4acf02793580e0f0c1bc380389527325b6254.zip
Cookies middleware
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb1
-rw-r--r--actionpack/test/controller/cookie_test.rb32
-rw-r--r--actionpack/test/dispatch/response_test.rb9
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb4
4 files changed, 11 insertions, 35 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 10913c0fdb..7b04638ccc 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -92,6 +92,7 @@ class ActionController::IntegrationTest < ActiveSupport::TestCase
middleware.use "ActionDispatch::ShowExceptions"
middleware.use "ActionDispatch::Callbacks"
middleware.use "ActionDispatch::ParamsParser"
+ middleware.use "ActionDispatch::Cookies"
middleware.use "ActionDispatch::Flash"
middleware.use "ActionDispatch::Head"
}.build(routes || ActionController::Routing::Routes)
diff --git a/actionpack/test/controller/cookie_test.rb b/actionpack/test/controller/cookie_test.rb
index c8e8b3857e..fd6538b27a 100644
--- a/actionpack/test/controller/cookie_test.rb
+++ b/actionpack/test/controller/cookie_test.rb
@@ -54,12 +54,12 @@ class CookieTest < ActionController::TestCase
cookies.permanent[:user_name] = "Jamie"
head :ok
end
-
+
def set_signed_cookie
cookies.signed[:user_id] = 45
head :ok
end
-
+
def set_permanent_signed_cookie
cookies.permanent.signed[:remember_me] = 100
head :ok
@@ -120,28 +120,6 @@ class CookieTest < ActionController::TestCase
assert_equal({"user_name" => nil}, @response.cookies)
end
- def test_cookiejar_accessor
- @request.cookies["user_name"] = "david"
- @controller.request = @request
- jar = ActionController::CookieJar.build(@controller.request, @controller.response)
- assert_equal "david", jar["user_name"]
- assert_equal nil, jar["something_else"]
- end
-
- def test_cookiejar_accessor_with_array_value
- @request.cookies["pages"] = %w{1 2 3}
- @controller.request = @request
- jar = ActionController::CookieJar.build(@controller.request, @controller.response)
- assert_equal %w{1 2 3}, jar["pages"]
- end
-
- def test_cookiejar_delete_removes_item_and_returns_its_value
- @request.cookies["user_name"] = "david"
- @controller.response = @response
- jar = ActionController::CookieJar.build(@controller.request, @controller.response)
- assert_equal "david", jar.delete("user_name")
- end
-
def test_delete_cookie_with_path
get :delete_cookie_with_path
assert_cookie_header "user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"
@@ -157,19 +135,19 @@ class CookieTest < ActionController::TestCase
assert_match /Jamie/, @response.headers["Set-Cookie"]
assert_match %r(#{20.years.from_now.utc.year}), @response.headers["Set-Cookie"]
end
-
+
def test_signed_cookie
get :set_signed_cookie
assert_equal 45, @controller.send(:cookies).signed[:user_id]
end
-
+
def test_permanent_signed_cookie
get :set_permanent_signed_cookie
assert_match %r(#{20.years.from_now.utc.year}), @response.headers["Set-Cookie"]
assert_equal 100, @controller.send(:cookies).signed[:remember_me]
end
-
+
private
def assert_cookie_header(expected)
header = @response.headers["Set-Cookie"]
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb
index 02f63f7006..4697fa3e2b 100644
--- a/actionpack/test/dispatch/response_test.rb
+++ b/actionpack/test/dispatch/response_test.rb
@@ -13,8 +13,7 @@ class ResponseTest < ActiveSupport::TestCase
assert_equal({
"Content-Type" => "text/html; charset=utf-8",
"Cache-Control" => "max-age=0, private, must-revalidate",
- "ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"',
- "Set-Cookie" => ""
+ "ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"'
}, headers)
parts = []
@@ -30,8 +29,7 @@ class ResponseTest < ActiveSupport::TestCase
assert_equal({
"Content-Type" => "text/html; charset=utf-8",
"Cache-Control" => "max-age=0, private, must-revalidate",
- "ETag" => '"ebb5e89e8a94e9dd22abf5d915d112b2"',
- "Set-Cookie" => ""
+ "ETag" => '"ebb5e89e8a94e9dd22abf5d915d112b2"'
}, headers)
end
@@ -44,8 +42,7 @@ class ResponseTest < ActiveSupport::TestCase
assert_equal 200, status
assert_equal({
"Content-Type" => "text/html; charset=utf-8",
- "Cache-Control" => "no-cache",
- "Set-Cookie" => ""
+ "Cache-Control" => "no-cache"
}, headers)
parts = []
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index ab7b9bc31b..d2c1758af1 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -137,7 +137,7 @@ class CookieStoreTest < ActionController::IntegrationTest
with_test_route_set do
get '/no_session_access'
assert_response :success
- assert_equal "", headers['Set-Cookie']
+ assert_equal nil, headers['Set-Cookie']
end
end
@@ -147,7 +147,7 @@ class CookieStoreTest < ActionController::IntegrationTest
"fef868465920f415f2c0652d6910d3af288a0367"
get '/no_session_access'
assert_response :success
- assert_equal "", headers['Set-Cookie']
+ assert_equal nil, headers['Set-Cookie']
end
end