diff options
Diffstat (limited to 'actionpack/lib/action_controller/test_case.rb')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 39cbc0cd70..fbbaa1a887 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -70,7 +70,7 @@ module ActionController self.content_type = ENCODER.content_type data = ENCODER.build_multipart non_path_parameters else - get_header('CONTENT_TYPE') do |k| + fetch_header('CONTENT_TYPE') do |k| set_header k, 'application/x-www-form-urlencoded' end @@ -78,7 +78,9 @@ module ActionController # params parser middleware, and we should remove this roundtripping # when we switch to caling `call` on the controller - case content_mime_type.ref + case content_mime_type.to_sym + when nil + raise "Unknown Content-Type: #{content_type}" when :json data = ActiveSupport::JSON.encode(non_path_parameters) params = ActiveSupport::JSON.decode(data).with_indifferent_access @@ -90,7 +92,8 @@ module ActionController when :url_encoded_form data = non_path_parameters.to_query else - raise "Unknown Content-Type: #{content_type}" + data = non_path_parameters.to_query + self.request_parameters = non_path_parameters end end @@ -98,7 +101,7 @@ module ActionController set_header 'rack.input', StringIO.new(data) end - get_header("PATH_INFO") do |k| + fetch_header("PATH_INFO") do |k| set_header k, generated_path end path_parameters[:controller] = controller_path @@ -149,7 +152,7 @@ module ActionController # Methods #destroy and #load! are overridden to avoid calling methods on the # @store object, which does not exist for the TestSession class. class TestSession < Rack::Session::Abstract::SessionHash #:nodoc: - DEFAULT_OPTIONS = Rack::Session::Abstract::ID::DEFAULT_OPTIONS + DEFAULT_OPTIONS = Rack::Session::Abstract::Persisted::DEFAULT_OPTIONS def initialize(session = {}) super(nil, nil) @@ -476,6 +479,7 @@ module ActionController end self.cookies.update @request.cookies + self.cookies.update_cookies_from_jar @request.set_header 'HTTP_COOKIE', cookies.to_header @request.delete_header 'action_dispatch.cookies' @@ -499,7 +503,7 @@ module ActionController if xhr @request.set_header 'HTTP_X_REQUESTED_WITH', 'XMLHttpRequest' - @request.get_header('HTTP_ACCEPT') do |k| + @request.fetch_header('HTTP_ACCEPT') do |k| @request.set_header k, [Mime::JS, Mime::HTML, Mime::XML, 'text/xml', Mime::ALL].join(', ') end end @@ -507,7 +511,7 @@ module ActionController @controller.request = @request @controller.response = @response - @request.get_header("SCRIPT_NAME") do |k| + @request.fetch_header("SCRIPT_NAME") do |k| @request.set_header k, @controller.config.relative_url_root end |