aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-16 10:46:03 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-06-16 10:46:03 -0700
commit18c3b77b2381e9f7072d595fa9f599b0994852a7 (patch)
tree979511c97310b34fccea57554a4ac7a0d9f6e805 /actionpack/lib/action_controller
parent1fbfa3e705c37656c308436f21d42b09591ba60e (diff)
downloadrails-18c3b77b2381e9f7072d595fa9f599b0994852a7.tar.gz
rails-18c3b77b2381e9f7072d595fa9f599b0994852a7.tar.bz2
rails-18c3b77b2381e9f7072d595fa9f599b0994852a7.zip
Merge process2 into process to people's regular tests run :P
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/testing/integration.rb2
-rw-r--r--actionpack/lib/action_controller/testing/process.rb51
-rw-r--r--actionpack/lib/action_controller/testing/process2.rb74
3 files changed, 12 insertions, 115 deletions
diff --git a/actionpack/lib/action_controller/testing/integration.rb b/actionpack/lib/action_controller/testing/integration.rb
index 37ca93f22c..5cb0f48f82 100644
--- a/actionpack/lib/action_controller/testing/integration.rb
+++ b/actionpack/lib/action_controller/testing/integration.rb
@@ -245,7 +245,7 @@ module ActionController
path = location.query ? "#{location.path}?#{location.query}" : location.path
end
- [ControllerCapture, ActionController::ProcessWithTest].each do |mod|
+ [ControllerCapture, ActionController::Testing].each do |mod|
unless ActionController::Base < mod
ActionController::Base.class_eval { include mod }
end
diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb
index ea5752d4f5..7634290ea1 100644
--- a/actionpack/lib/action_controller/testing/process.rb
+++ b/actionpack/lib/action_controller/testing/process.rb
@@ -124,30 +124,24 @@ module ActionController #:nodoc:
@request.recycle!
@response.recycle!
+ @controller.response_body = nil
+ @controller.formats = nil
+ @controller.params = nil
@html_document = nil
- @request.request_method = http_method
+ @request.env['REQUEST_METHOD'] = http_method
parameters ||= {}
@request.assign_parameters(@controller.class.controller_path, action.to_s, parameters)
@request.session = ActionController::TestSession.new(session) unless session.nil?
@request.session["flash"] = ActionController::Flash::FlashHash.new.update(flash) if flash
- build_request_uri(action, parameters)
-
- Base.class_eval { include ProcessWithTest } unless Base < ProcessWithTest
-
- env = @request.env
- app = @controller
-
- # TODO: Enable Lint
- # app = Rack::Lint.new(app)
- status, headers, body = app.action(action, env)
- response = Rack::MockResponse.new(status, headers, body)
-
- @response.request, @response.template = @request, @controller.template
- @response.status, @response.headers, @response.body = response.status, response.headers, response.body
+ @controller.request = @request
+ @controller.params.merge!(parameters)
+ build_request_uri(action, parameters)
+ Base.class_eval { include Testing }
+ @controller.process_with_new_base_test(@request, @response)
@response
end
@@ -167,7 +161,7 @@ module ActionController #:nodoc:
next if ActionController::Base.protected_instance_variables.include?(ivar)
assigns[ivar[1..-1]] = @controller.instance_variable_get(ivar)
end
-
+
key.nil? ? assigns : assigns[key.to_s]
end
@@ -263,27 +257,4 @@ module ActionController #:nodoc:
ActionController::Routing.const_set(:Routes, real_routes) if real_routes
end
end
-
- module ProcessWithTest #:nodoc:
- def self.included(base)
- base.class_eval {
- attr_reader :assigns
- alias_method_chain :process, :test
- }
- end
-
- def process_with_test(*args)
- process_without_test(*args).tap { set_test_assigns }
- end
-
- private
- def set_test_assigns
- @assigns = {}
- (instance_variable_names - self.class.protected_instance_variables).each do |var|
- name, value = var[1..-1], instance_variable_get(var)
- @assigns[name] = value
- @template.assigns[name] = value if response
- end
- end
- end
-end
+end \ No newline at end of file
diff --git a/actionpack/lib/action_controller/testing/process2.rb b/actionpack/lib/action_controller/testing/process2.rb
deleted file mode 100644
index 1c6fd2d80a..0000000000
--- a/actionpack/lib/action_controller/testing/process2.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require "action_controller/testing/process"
-
-module ActionController
- module TestProcess
-
- # Executes a request simulating GET HTTP method and set/volley the response
- def get(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "GET")
- end
-
- # Executes a request simulating POST HTTP method and set/volley the response
- def post(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "POST")
- end
-
- # Executes a request simulating PUT HTTP method and set/volley the response
- def put(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "PUT")
- end
-
- # Executes a request simulating DELETE HTTP method and set/volley the response
- def delete(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "DELETE")
- end
-
- # Executes a request simulating HEAD HTTP method and set/volley the response
- def head(action, parameters = nil, session = nil, flash = nil)
- process(action, parameters, session, flash, "HEAD")
- end
-
- def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
- # Sanity check for required instance variables so we can give an
- # understandable error message.
- %w(@controller @request @response).each do |iv_name|
- if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
- raise "#{iv_name} is nil: make sure you set it in your test's setup method."
- end
- end
-
- @request.recycle!
- @response.recycle!
- @controller.response_body = nil
- @controller.formats = nil
- @controller.params = nil
-
- @html_document = nil
- @request.env['REQUEST_METHOD'] = http_method
-
- parameters ||= {}
- @request.assign_parameters(@controller.class.controller_path, action.to_s, parameters)
-
- @request.session = ActionController::TestSession.new(session) unless session.nil?
- @request.session["flash"] = ActionController::Flash::FlashHash.new.update(flash) if flash
-
- @controller.request = @request
- @controller.params.merge!(parameters)
- build_request_uri(action, parameters)
- # Base.class_eval { include ProcessWithTest } unless Base < ProcessWithTest
- @controller.process_with_new_base_test(@request, @response)
- @response
- end
-
- def build_request_uri(action, parameters)
- unless @request.env['REQUEST_URI']
- options = @controller.__send__(:rewrite_options, parameters)
- options.update(:only_path => true, :action => action)
-
- url = ActionController::UrlRewriter.new(@request, parameters)
- @request.request_uri = url.rewrite(options)
- end
- end
-
- end
-end \ No newline at end of file