aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/integration.rb
diff options
context:
space:
mode:
authorColin Curtin <colin@procore.com>2008-12-20 20:21:20 -0800
committerColin Curtin <colin@procore.com>2008-12-20 20:21:20 -0800
commit0e121f9ed93ebb417cc63307aaaf47f8adfd220d (patch)
tree39530f289b38a5dd1b2e6b170dab2631c983aaf3 /actionpack/lib/action_controller/integration.rb
parentb0187434bd7601a5b2e5f7afac99c964e566b9db (diff)
parenta0d091a41604d709cf2b99c85dcf4ae3ee275b9c (diff)
downloadrails-0e121f9ed93ebb417cc63307aaaf47f8adfd220d.tar.gz
rails-0e121f9ed93ebb417cc63307aaaf47f8adfd220d.tar.bz2
rails-0e121f9ed93ebb417cc63307aaaf47f8adfd220d.zip
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'actionpack/lib/action_controller/integration.rb')
-rw-r--r--actionpack/lib/action_controller/integration.rb29
1 files changed, 18 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index 1b0543033b..7590d5d710 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -276,6 +276,7 @@ module ActionController
"SCRIPT_NAME" => "",
"REQUEST_URI" => path,
+ "PATH_INFO" => path,
"HTTP_HOST" => host,
"REMOTE_ADDR" => remote_addr,
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
@@ -290,7 +291,7 @@ module ActionController
"rack.multiprocess" => true,
"rack.run_once" => false,
- "action_controller.test" => true
+ "rack.test" => true
)
(headers || {}).each do |key, value|
@@ -310,16 +311,6 @@ module ActionController
status, headers, body = app.call(env)
@request_count += 1
- if @controller = ActionController::Base.last_instantiation
- @request = @controller.request
- @response = @controller.response
-
- # Decorate the response with the standard behavior of the
- # TestResponse so that things like assert_response can be
- # used in integration tests.
- @response.extend(TestResponseBehavior)
- end
-
@html_document = nil
@status = status.to_i
@@ -335,6 +326,22 @@ module ActionController
@body = ""
body.each { |part| @body << part }
+ if @controller = ActionController::Base.last_instantiation
+ @request = @controller.request
+ @response = @controller.response
+ else
+ # Decorate responses from Rack Middleware and Rails Metal
+ # as an AbstractResponse for the purposes of integration testing
+ @response = AbstractResponse.new
+ @response.headers = @headers.merge('Status' => status.to_s)
+ @response.body = @body
+ end
+
+ # Decorate the response with the standard behavior of the
+ # TestResponse so that things like assert_response can be
+ # used in integration tests.
+ @response.extend(TestResponseBehavior)
+
return @status
rescue MultiPartNeededException
boundary = "----------XnJLe9ZIbbGUYtzPQJ16u1"