diff options
author | Elia Schito <elia@schito.me> | 2012-11-26 23:49:14 +0100 |
---|---|---|
committer | Elia Schito <elia@schito.me> | 2012-11-27 00:25:55 +0100 |
commit | 9c33cb26f409845cde5cd5f4298a94ac8a887f1d (patch) | |
tree | f64f02bcdd17fae1e633374b20003e037402e653 | |
parent | 941f0196c6c8eade08bf19307bdbedaaeadbe291 (diff) | |
download | rails-9c33cb26f409845cde5cd5f4298a94ac8a887f1d.tar.gz rails-9c33cb26f409845cde5cd5f4298a94ac8a887f1d.tar.bz2 rails-9c33cb26f409845cde5cd5f4298a94ac8a887f1d.zip |
Accept symbols as #send_data :disposition value
-rw-r--r-- | actionpack/CHANGELOG.md | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/data_streaming.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/send_file_test.rb | 14 |
3 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index d20a949454..10bba63390 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 3.2.10 (unreleased) ## +* Accept symbols as #send_data :disposition value. [Backport #8329] *Elia Schito* + * Add i18n scope to distance_of_time_in_words. [Backport #7997] *Steve Klabnik* * Fix side effect of `url_for` changing the `:controller` string option. [Backport #6003] diff --git a/actionpack/lib/action_controller/metal/data_streaming.rb b/actionpack/lib/action_controller/metal/data_streaming.rb index 62e16ea047..95c058fc86 100644 --- a/actionpack/lib/action_controller/metal/data_streaming.rb +++ b/actionpack/lib/action_controller/metal/data_streaming.rb @@ -141,7 +141,7 @@ module ActionController #:nodoc: raise ArgumentError, ":#{arg} option required" if options[arg].nil? end - disposition = options[:disposition] + disposition = options[:disposition].to_s disposition += %(; filename="#{options[:filename]}") if options[:filename] content_type = options[:type] diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index 8f885ff28e..4e4dd8d005 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -118,6 +118,18 @@ class SendFileTest < ActionController::TestCase assert_equal 'private', h['Cache-Control'] end + def test_send_file_headers_with_disposition_as_a_symbol + options = { + :type => Mime::PNG, + :disposition => :disposition, + :filename => 'filename' + } + + @controller.headers = {} + @controller.send(:send_file_headers!, options) + assert_equal 'disposition; filename="filename"', @controller.headers['Content-Disposition'] + end + def test_send_file_headers_with_mime_lookup_with_symbol options = { :type => :png @@ -138,7 +150,7 @@ 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', |