diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-12-22 23:13:04 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-12-23 00:30:32 +0000 |
commit | b5ecfe78f9fb3b06f4fec4815b5e79399e4993aa (patch) | |
tree | 42febcdf9342ac681275fc87f958fbacff04578d | |
parent | 7e1751111ecf3886eba313fef183d73ff1f07eb6 (diff) | |
download | rails-b5ecfe78f9fb3b06f4fec4815b5e79399e4993aa.tar.gz rails-b5ecfe78f9fb3b06f4fec4815b5e79399e4993aa.tar.bz2 rails-b5ecfe78f9fb3b06f4fec4815b5e79399e4993aa.zip |
Use Rack::MockRequest for TestRequest
-rw-r--r-- | actionpack/lib/action_controller/assertions/routing_assertions.rb | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_process.rb | 14 |
3 files changed, 9 insertions, 20 deletions
diff --git a/actionpack/lib/action_controller/assertions/routing_assertions.rb b/actionpack/lib/action_controller/assertions/routing_assertions.rb index 8a837c592c..5101751cea 100644 --- a/actionpack/lib/action_controller/assertions/routing_assertions.rb +++ b/actionpack/lib/action_controller/assertions/routing_assertions.rb @@ -134,7 +134,7 @@ module ActionController path = "/#{path}" unless path.first == '/' # Assume given controller - request = ActionController::TestRequest.new({}, {}, nil) + request = ActionController::TestRequest.new request.env["REQUEST_METHOD"] = request_method.to_s.upcase if request_method request.path = path diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 565a2d5d81..a3e96a0fc4 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -7,7 +7,7 @@ require 'action_controller/cgi_ext' module ActionController # CgiRequest and TestRequest provide concrete implementations. - class AbstractRequest + class AbstractRequest < Rack::Request extend ActiveSupport::Memoizable HTTP_METHODS = %w(get head put post delete options) @@ -424,7 +424,6 @@ EOM end alias referer referrer - def query_parameters @query_parameters ||= self.class.parse_query_parameters(query_string) end @@ -433,7 +432,6 @@ EOM @request_parameters ||= parse_formatted_request_parameters end - #-- # Must be implemented in the concrete request #++ @@ -868,11 +866,6 @@ EOM class SessionFixationAttempt < StandardError #:nodoc: end - def initialize(env) - @env = env - super() - end - %w[ AUTH_TYPE GATEWAY_INTERFACE PATH_INFO PATH_TRANSLATED REMOTE_HOST REMOTE_IDENT REMOTE_USER SCRIPT_NAME @@ -911,10 +904,6 @@ EOM @env['SERVER_PORT'].to_i end - def server_software - @env['SERVER_SOFTWARE'].split("/").first - end - def session_options @env['rack.session.options'] ||= {} end diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 45dcf8b2c2..211e22ff58 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -27,20 +27,20 @@ module ActionController #:nodoc: alias_method_chain :process, :test end - class TestRequest < AbstractRequest #:nodoc: + class TestRequest < Request #:nodoc: attr_accessor :cookies, :session_options attr_accessor :query_parameters, :request_parameters, :path, :session attr_accessor :host, :user_agent - def initialize(query_parameters = nil, request_parameters = nil, session = nil) - @query_parameters = query_parameters || {} - @request_parameters = request_parameters || {} - @session = session || TestSession.new + def initialize + super(Rack::MockRequest.env_for('/')) + + @query_parameters = {} + @request_parameters = {} + @session = TestSession.new initialize_containers initialize_default_values - - super() end def reset_session |