From 47b6fe06824893f9b0c4628e766f387956cabf22 Mon Sep 17 00:00:00 2001 From: brainopia Date: Thu, 15 Jan 2015 22:35:40 +0300 Subject: Add ActionController#build_with_env To have an easier way to setup a controller instance with custom environment --- actionpack/lib/action_controller/metal/rack_delegation.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'actionpack/lib') 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) -- cgit v1.2.3