From 5352a2417b9f6297d16a6baefd1994be4d1e4a12 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 26 Apr 2009 11:12:33 -0500 Subject: Move useful response test helpers into request --- actionpack/test/dispatch/response_test.rb | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'actionpack/test/dispatch') 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 -- cgit v1.2.3