Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use Rack::MockRequest for TestRequest

  • Loading branch information...
commit b5ecfe78f9fb3b06f4fec4815b5e79399e4993aa 1 parent 7e17511
@lifo lifo authored
View
2  actionpack/lib/action_controller/assertions/routing_assertions.rb
@@ -134,7 +134,7 @@ def recognized_request_for(path, request_method = nil)
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
View
13 actionpack/lib/action_controller/request.rb
@@ -7,7 +7,7 @@
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 @@ def referrer
end
alias referer referrer
-
def query_parameters
@query_parameters ||= self.class.parse_query_parameters(query_string)
end
@@ -433,7 +432,6 @@ def request_parameters
@request_parameters ||= parse_formatted_request_parameters
end
-
#--
# Must be implemented in the concrete request
#++
@@ -868,11 +866,6 @@ class Request < AbstractRequest #:nodoc:
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 @@ def server_port
@env['SERVER_PORT'].to_i
end
- def server_software
- @env['SERVER_SOFTWARE'].split("/").first
- end
-
def session_options
@env['rack.session.options'] ||= {}
end
View
14 actionpack/lib/action_controller/test_process.rb
@@ -27,20 +27,20 @@ def process_with_test(*args)
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
Please sign in to comment.
Something went wrong with that request. Please try again.