From 3adcd71a4e8102811692360ab2282cb7094beb38 Mon Sep 17 00:00:00 2001 From: Kamal Fariz Mahyuddin Date: Mon, 15 Jun 2009 23:31:05 +0800 Subject: [PATCH] Replace response headers the long way so that Rack::Utils::HeaderHash @names gets populated correctly --- actionpack/lib/action_controller/integration.rb | 3 ++- actionpack/test/controller/integration_test.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletions(-) diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb index 58b6476..61a1c86 100644 --- a/actionpack/lib/action_controller/integration.rb +++ b/actionpack/lib/action_controller/integration.rb @@ -341,7 +341,8 @@ module ActionController # as an Response for the purposes of integration testing @response = Response.new @response.status = status.to_s - @response.headers.replace(@headers) + @response.headers.clear + @headers.each { |k,v| @response.headers[k] = v } @response.body = @body end diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb index b8281b5..4e822dc 100644 --- a/actionpack/test/controller/integration_test.rb +++ b/actionpack/test/controller/integration_test.rb @@ -418,6 +418,8 @@ class MetalTest < ActionController::IntegrationTest def self.call(env) if env["PATH_INFO"] =~ /^\/success/ [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, ["Hello World!"]] + elsif env["PATH_INFO"] =~ /^\/redirect/ + [302, {"Content-Type" => "text/plain", "Content-Length" => "0", "Location" => "/success"}, []] else [404, {"Content-Type" => "text/plain", "Content-Length" => "0"}, []] end @@ -442,4 +444,11 @@ class MetalTest < ActionController::IntegrationTest assert_response :not_found assert_equal '', response.body end + + def test_redirected_get + get "/redirect" + assert_response 302 + assert_response :redirect + assert_equal headers["Location"], response.headers["Location"] + end end -- 1.6.2.4