diff options
author | Esad Hajdarevic <esad@esse.at> | 2011-06-28 06:57:41 +0200 |
---|---|---|
committer | Esad Hajdarevic <esad@esse.at> | 2011-06-28 06:58:28 +0200 |
commit | 2a61d47b5537bf94fae2f2c4cb97569a71a09fd7 (patch) | |
tree | b7c167913424932d9c8732c22ea62a8dd5eebc2e /actionpack/test | |
parent | d73269ba53992d8a01e5721aad3d23bc2b11dc4f (diff) | |
download | rails-2a61d47b5537bf94fae2f2c4cb97569a71a09fd7.tar.gz rails-2a61d47b5537bf94fae2f2c4cb97569a71a09fd7.tar.bz2 rails-2a61d47b5537bf94fae2f2c4cb97569a71a09fd7.zip |
Make send_file guess content-type from file extension, if type wasn't supplied (Issue #1847). Update tests & documentation.
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/controller/send_file_test.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index c7c8360ae6..8f885ff28e 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -138,6 +138,25 @@ class SendFileTest < ActionController::TestCase @controller.headers = {} assert_raise(ArgumentError){ @controller.send(:send_file_headers!, options) } end + + def test_send_file_headers_guess_type_from_extension + { + 'image.png' => 'image/png', + 'image.jpeg' => 'image/jpeg', + 'image.jpg' => 'image/jpeg', + 'image.tif' => 'image/tiff', + 'image.gif' => 'image/gif', + 'movie.mpg' => 'video/mpeg', + 'file.zip' => 'application/zip', + 'file.unk' => 'application/octet-stream', + 'zip' => 'application/octet-stream' + }.each do |filename,expected_type| + options = { :filename => filename } + @controller.headers = {} + @controller.send(:send_file_headers!, options) + assert_equal expected_type, @controller.content_type + end + end %w(file data).each do |method| define_method "test_send_#{method}_status" do |