diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-20 14:43:59 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-01-20 14:43:59 +0000 |
commit | 93f7cb2a80b53d38eb01aaeade8f5c8bf13090f2 (patch) | |
tree | 2bce38b3797a751e97c40f5ff47ffdd0e603b716 /actionpack | |
parent | b40d3c9e62325512e167b6fccc7d9d1a60948faa (diff) | |
download | rails-93f7cb2a80b53d38eb01aaeade8f5c8bf13090f2.tar.gz rails-93f7cb2a80b53d38eb01aaeade8f5c8bf13090f2.tar.bz2 rails-93f7cb2a80b53d38eb01aaeade8f5c8bf13090f2.zip |
Added TestResponse#binary_content that'll return as a string the data sent through send_data/send_file for testing #500 [Alexey]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@467 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_process.rb | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 29306668c7..bd76b3f61d 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added TestResponse#binary_content that'll return as a string the data sent through send_data/send_file for testing #500 [Alexey] + * Added @request.env['RAW_POST_DATA'] for people who need access to the data before Ruby's CGI has parsed it #505 [bitsweat] * Fixed that a default fragment store wan't being set to MemoryStore as intended. diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 6fd5249836..2ab955b677 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -191,6 +191,23 @@ module ActionController #:nodoc: headers['cookie'].inject({}) { |hash, cookie| hash[cookie.name] = cookie; hash } end + # Returns binary content (downloadable file), converted to a String + def binary_content + raise "Response body is not a Proc: #{body.inspect}" unless body.kind_of?(Proc) + require 'stringio' + + sio = StringIO.new + + begin + $stdout = sio + body.call + ensure + $stdout = STDOUT + end + + sio.rewind + sio.read + end end class TestSession #:nodoc: |