From b8b7664415f9d6668156280a8ed051dc04786115 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 18 Sep 2015 14:32:20 -0700 Subject: let the request object handle parsing XML posts The test request object will handle parsing XML posts now, so we don't need to eagerly parse them in the test harness --- actionpack/lib/action_controller/test_case.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index c2f07b2373..c360cfd542 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -33,6 +33,9 @@ module ActionController self.session = session self.session_options = TestSession::DEFAULT_OPTIONS + @custom_param_parsers = { + Mime::XML => lambda { |raw_post| Hash.from_xml(raw_post)['hash'] } + } end def query_string=(string) @@ -85,8 +88,6 @@ module ActionController data = ActiveSupport::JSON.encode(non_path_parameters) when :xml data = non_path_parameters.to_xml - params = Hash.from_xml(data)['hash'] - self.request_parameters = params when :url_encoded_form data = non_path_parameters.to_query else @@ -134,6 +135,12 @@ module ActionController "multipart/form-data; boundary=#{Rack::Test::MULTIPART_BOUNDARY}" end end.new + + private + + def params_parsers + super.merge @custom_param_parsers + end end class LiveTestResponse < Live::Response -- cgit v1.2.3