Permalink
Browse files

Added tests for cookies with domain option.

  • Loading branch information...
1 parent 132730d commit 51ad68367a5ea67aee586c6bd9b4017088a093ce @rizwanreza rizwanreza committed with josevalim Jun 11, 2010
Showing with 22 additions and 0 deletions.
  1. +22 −0 actionpack/test/dispatch/cookies_test.rb
View
22 actionpack/test/dispatch/cookies_test.rb
@@ -79,6 +79,16 @@ def delete_and_set_cookie
cookies[:user_name] = { :value => "david", :expires => Time.utc(2005, 10, 10,5) }
head :ok
end
+
+ def set_cookie_with_domain
+ cookies[:user_name] = {:value => "rizwanreza", :domain => :all}
+ head :ok
+ end
+
+ def delete_cookie_with_domain
+ cookies.delete(:user_name, :domain => :all)
+ head :ok
+ end
end
tests TestController
@@ -216,6 +226,18 @@ def test_raises_argument_error_if_secret_is_probably_insecure
}
end
+ def test_cookie_with_all_domain_option
+ get :set_cookie_with_domain
+ assert_response :success
+ assert_cookie_header "user_name=rizwanreza; domain=.nextangle.com; path=/"
+ end
+
+ def test_deleting_cookie_with_all_domain_option
+ get :delete_cookie_with_domain
+ assert_response :success
+ assert_cookie_header "user_name=; domain=.nextangle.com; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT"
+ end
+
private
def assert_cookie_header(expected)
header = @response.headers["Set-Cookie"]

0 comments on commit 51ad683

Please sign in to comment.