aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorbrainopia <brainopia@evilmartians.com>2015-01-15 22:35:40 +0300
committerbrainopia <brainopia@evilmartians.com>2015-01-22 00:26:06 +0300
commit47b6fe06824893f9b0c4628e766f387956cabf22 (patch)
treedd7a184998a167d7985828b5a5f908ab1bdc1768 /actionpack/lib
parent685142e4f46292190cedb1d9c69953a948ea92fc (diff)
downloadrails-47b6fe06824893f9b0c4628e766f387956cabf22.tar.gz
rails-47b6fe06824893f9b0c4628e766f387956cabf22.tar.bz2
rails-47b6fe06824893f9b0c4628e766f387956cabf22.zip
Add ActionController#build_with_env
To have an easier way to setup a controller instance with custom environment
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/metal/rack_delegation.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/rack_delegation.rb b/actionpack/lib/action_controller/metal/rack_delegation.rb
index 82054880e9..ae9d89cc8c 100644
--- a/actionpack/lib/action_controller/metal/rack_delegation.rb
+++ b/actionpack/lib/action_controller/metal/rack_delegation.rb
@@ -8,6 +8,12 @@ module ActionController
delegate :headers, :status=, :location=, :content_type=,
:status, :location, :content_type, :response_code, :to => "@_response"
+ module ClassMethods
+ def build_with_env(env = {}) #:nodoc:
+ new.tap { |c| c.set_request! ActionDispatch::Request.new(env) }
+ end
+ end
+
def set_request!(request) #:nodoc:
super
set_response!(request)