diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-01-20 08:59:26 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-20 09:00:23 -0600 |
commit | 909443eab67c4f07aeb6a294e3858792f075b3ab (patch) | |
tree | 92bb679ab3039d2fe944c51e15b106da192bb43c /actionpack/lib/action_dispatch | |
parent | d1ffc54c06fbacf46783f5ebc84bc125c9188fd1 (diff) | |
download | rails-909443eab67c4f07aeb6a294e3858792f075b3ab.tar.gz rails-909443eab67c4f07aeb6a294e3858792f075b3ab.tar.bz2 rails-909443eab67c4f07aeb6a294e3858792f075b3ab.zip |
Expose last controller in rack env["action_controller.instance"]
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index d4c9df7ebd..2093bb3a0e 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -240,9 +240,9 @@ module ActionDispatch path = location.query ? "#{location.path}?#{location.query}" : location.path end - [ControllerCapture, ActionController::Testing].each do |mod| - unless ActionController::Base < mod - ActionController::Base.class_eval { include mod } + unless ActionController::Base < ActionController::Testing + ActionController::Base.class_eval do + include ActionController::Testing end end @@ -269,16 +269,15 @@ module ActionDispatch end session = Rack::Test::Session.new(@mock_session) - - @controller = ActionController::Base.capture_instantiation do - session.request(path, env) - end + session.request(path, env) @request_count += 1 @request = ActionDispatch::Request.new(session.last_request.env) @response = ActionDispatch::TestResponse.from_response(@mock_session.last_response) @html_document = nil + @controller = session.last_request.env['action_controller.instance'] + return response.status end @@ -296,31 +295,6 @@ module ActionDispatch end end - # A module used to extend ActionController::Base, so that integration tests - # can capture the controller used to satisfy a request. - module ControllerCapture #:nodoc: - extend ActiveSupport::Concern - - included do - alias_method_chain :initialize, :capture - end - - def initialize_with_capture(*args) - initialize_without_capture - self.class.last_instantiation ||= self - end - - module ClassMethods #:nodoc: - mattr_accessor :last_instantiation - - def capture_instantiation - self.last_instantiation = nil - yield - return last_instantiation - end - end - end - module Runner def app @app |