mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Move TestRequest#query_parameters into AD TestRequest
This commit is contained in:
@@ -2,20 +2,13 @@ require 'rack/session/abstract/id'
|
||||
|
||||
module ActionController #:nodoc:
|
||||
class TestRequest < ActionDispatch::TestRequest #:nodoc:
|
||||
attr_accessor :query_parameters
|
||||
|
||||
def initialize(env = {})
|
||||
super
|
||||
|
||||
@query_parameters = {}
|
||||
self.session = TestSession.new
|
||||
self.session_options = TestSession::DEFAULT_OPTIONS.merge(:id => ActiveSupport::SecureRandom.hex(16))
|
||||
end
|
||||
|
||||
def action=(action_name)
|
||||
query_parameters.update({ "action" => action_name })
|
||||
end
|
||||
|
||||
def assign_parameters(controller_path, action, parameters)
|
||||
parameters = parameters.symbolize_keys.merge(:controller => controller_path, :action => action)
|
||||
extra_keys = ActionController::Routing::Routes.extra_keys(parameters)
|
||||
@@ -47,9 +40,8 @@ module ActionController #:nodoc:
|
||||
end
|
||||
|
||||
def recycle!
|
||||
@env.delete_if { |k, v| k =~ /^action_dispatch\.request/ }
|
||||
self.query_parameters = {}
|
||||
@headers = nil
|
||||
@env.delete_if { |k, v| k =~ /^(action_dispatch|rack)\.request/ }
|
||||
@env['action_dispatch.request.query_parameters'] = {}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -132,8 +124,6 @@ module ActionController #:nodoc:
|
||||
@html_document = nil
|
||||
@request.request_method = http_method
|
||||
|
||||
@request.action = action.to_s
|
||||
|
||||
parameters ||= {}
|
||||
@request.assign_parameters(@controller.class.controller_path, action.to_s, parameters)
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ EOM
|
||||
|
||||
# Returns the query string, accounting for server idiosyncrasies.
|
||||
def query_string
|
||||
@env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].split('?', 2)[1] || '')
|
||||
@env['QUERY_STRING'].present? ? @env['QUERY_STRING'] : (@env['REQUEST_URI'].to_s.split('?', 2)[1] || '')
|
||||
end
|
||||
|
||||
# Returns the request URI, accounting for server idiosyncrasies.
|
||||
|
||||
@@ -39,6 +39,10 @@ module ActionDispatch
|
||||
@env['PATH_INFO'] = path
|
||||
end
|
||||
|
||||
def action=(action_name)
|
||||
path_parameters["action"] = action_name.to_s
|
||||
end
|
||||
|
||||
def if_modified_since=(last_modified)
|
||||
@env['HTTP_IF_MODIFIED_SINCE'] = last_modified
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user