diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-23 19:09:37 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-05-23 19:09:37 +0000 |
commit | 4bd3e3aa1b92c75fafbb727820aeacae5e9bcb42 (patch) | |
tree | c2b9757a7ab8e30babacfebfc4258dad55250f8b /actionpack/test/controller | |
parent | 7b99b403521f0a4c15903c1672cb22acb65f0afb (diff) | |
download | rails-4bd3e3aa1b92c75fafbb727820aeacae5e9bcb42.tar.gz rails-4bd3e3aa1b92c75fafbb727820aeacae5e9bcb42.tar.bz2 rails-4bd3e3aa1b92c75fafbb727820aeacae5e9bcb42.zip |
Set RAW_POST_DATA when request parameters are parsed.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6823 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/request_test.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 4ec31b389c..4a43091823 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -708,9 +708,7 @@ class MultipartRequestParameterParsingTest < Test::Unit::TestCase private def process(name) File.open(File.join(FIXTURE_PATH, name), 'rb') do |file| - content_length = file.stat.size.to_s - content_type = 'multipart/form-data, boundary=AaB03x' - ActionController::AbstractRequest.parse_formatted_request_parameters(file, content_type, content_length) + ActionController::AbstractRequest.parse_multipart_form_parameters(file, 'AaB03x', file.stat.size, {}) end end end @@ -718,9 +716,7 @@ end class XmlParamsParsingTest < Test::Unit::TestCase def test_single_file - body = "<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{Base64.encode64('ABC')}</avatar></person>" - - person = ActionController::AbstractRequest.parse_formatted_request_parameters(StringIO.new(body), 'application/xml', body.size) + person = parse_body("<person><name>David</name><avatar type='file' name='me.jpg' content_type='image/jpg'>#{Base64.encode64('ABC')}</avatar></person>") assert_equal "image/jpg", person['person']['avatar'].content_type assert_equal "me.jpg", person['person']['avatar'].original_filename @@ -728,7 +724,7 @@ class XmlParamsParsingTest < Test::Unit::TestCase end def test_multiple_files - body = <<-end_body + person = parse_body(<<-end_body) <person> <name>David</name> <avatars> @@ -738,8 +734,6 @@ class XmlParamsParsingTest < Test::Unit::TestCase </person> end_body - person = ActionController::AbstractRequest.parse_formatted_request_parameters(StringIO.new(body), 'application/xml', body.size) - assert_equal "image/jpg", person['person']['avatars']['avatar'].first.content_type assert_equal "me.jpg", person['person']['avatars']['avatar'].first.original_filename assert_equal "ABC", person['person']['avatars']['avatar'].first.read @@ -748,4 +742,12 @@ class XmlParamsParsingTest < Test::Unit::TestCase assert_equal "you.gif", person['person']['avatars']['avatar'].last.original_filename assert_equal "DEF", person['person']['avatars']['avatar'].last.read end + + private + def parse_body(body) + env = { 'CONTENT_TYPE' => 'application/xml', + 'CONTENT_LENGTH' => body.size.to_s } + cgi = ActionController::Integration::Session::MockCGI.new(env, body) + ActionController::CgiRequest.new(cgi).request_parameters + end end |