diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-18 14:35:48 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-18 14:35:48 -0700 |
commit | a9334616120cffb560017e6a563ad401e425602b (patch) | |
tree | 0b2817c02e95a7966c82c261264cbdf1f946f2a6 /actionpack/lib/action_controller | |
parent | 77370f27db8b70f67756e6948a4bd4a102cdbb7a (diff) | |
parent | 58dba19a0b0e4f71927b3262970f0d5dcb8990ea (diff) | |
download | rails-a9334616120cffb560017e6a563ad401e425602b.tar.gz rails-a9334616120cffb560017e6a563ad401e425602b.tar.bz2 rails-a9334616120cffb560017e6a563ad401e425602b.zip |
Merge branch 'pp'
* pp:
remove outdated comment
all parameter parsing is done through the request object now.
let the request object handle parsing XML posts
remove setting request parameters for JSON requests
remove the request parameter from `parse_formatted_parameters`
do not instantiate a param parser middleware
push the parameter parsers on to the class
stop eagerly parsing parameters
only wrap the strategy with exception handling
pull `normalize_encode_params` up
remove the `default` parameter from the parser method
move parameter parsing to the request object
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/test_case.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index fbbaa1a887..f16c851456 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) @@ -74,26 +77,18 @@ module ActionController set_header k, 'application/x-www-form-urlencoded' end - # FIXME: setting `request_parametes` is normally handled by the - # params parser middleware, and we should remove this roundtripping - # when we switch to caling `call` on the controller - 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 - self.request_parameters = params 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 + @custom_param_parsers[content_mime_type] = ->(_) { non_path_parameters } data = non_path_parameters.to_query - self.request_parameters = non_path_parameters end end @@ -136,6 +131,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 |