aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-04-26 11:12:33 -0500
committerJoshua Peek <josh@joshpeek.com>2009-04-26 11:12:33 -0500
commit5352a2417b9f6297d16a6baefd1994be4d1e4a12 (patch)
tree38c734e7005d3ac5c28fd72cee2c04ef1801c944 /actionpack/test/dispatch
parentdbbe2e74ff5b6363da74fe63045b043c24041b1a (diff)
downloadrails-5352a2417b9f6297d16a6baefd1994be4d1e4a12.tar.gz
rails-5352a2417b9f6297d16a6baefd1994be4d1e4a12.tar.bz2
rails-5352a2417b9f6297d16a6baefd1994be4d1e4a12.zip
Move useful response test helpers into request
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/response_test.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb
index fb593a6c31..2ddc6cb2b5 100644
--- a/actionpack/test/dispatch/response_test.rb
+++ b/actionpack/test/dispatch/response_test.rb
@@ -80,4 +80,51 @@ class ResponseTest < ActiveSupport::TestCase
status, headers, body = @response.to_a
assert !headers.has_key?('Status')
end
+
+ test "response code" do
+ @response.status = "200 OK"
+ assert_equal 200, @response.response_code
+
+ @response.status = "200"
+ assert_equal 200, @response.response_code
+
+ @response.status = 200
+ assert_equal 200, @response.response_code
+ end
+
+ test "code" do
+ @response.status = "200 OK"
+ assert_equal "200", @response.code
+
+ @response.status = "200"
+ assert_equal "200", @response.code
+
+ @response.status = 200
+ assert_equal "200", @response.code
+ end
+
+ test "message" do
+ @response.status = "200 OK"
+ assert_equal "OK", @response.message
+
+ @response.status = "200"
+ assert_equal "OK", @response.message
+
+ @response.status = 200
+ assert_equal "OK", @response.message
+ end
+
+ test "cookies" do
+ @response.set_cookie("user_name", :value => "david", :path => "/")
+ @response.prepare!
+ status, headers, body = @response.to_a
+ assert_equal "user_name=david; path=/", headers["Set-Cookie"]
+ assert_equal({"user_name" => "david"}, @response.cookies)
+
+ @response.set_cookie("login", :value => "foo&bar", :path => "/", :expires => Time.utc(2005, 10, 10,5))
+ @response.prepare!
+ status, headers, body = @response.to_a
+ assert_equal "user_name=david; path=/\nlogin=foo%26bar; path=/; expires=Mon, 10-Oct-2005 05:00:00 GMT", headers["Set-Cookie"]
+ assert_equal({"login" => "foo&bar", "user_name" => "david"}, @response.cookies)
+ end
end