aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-26 15:34:09 -0800
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-26 15:34:09 -0800
commitfe4571259daab2738908da83b0c2c4387ba139e5 (patch)
treef3e09b588ae9cba565649552e2ebccdc9f098514
parent5658923daa2f2c7858f55844168e1872cc611766 (diff)
parent5d8faa683e230e6af54ac7616f98f3ae088e7682 (diff)
downloadrails-fe4571259daab2738908da83b0c2c4387ba139e5.tar.gz
rails-fe4571259daab2738908da83b0c2c4387ba139e5.tar.bz2
rails-fe4571259daab2738908da83b0c2c4387ba139e5.zip
Merge pull request #8329 from elia/fix-send-data-disposition-with-symbols-master
Accept symbols as #send_data :disposition value
-rw-r--r--actionpack/CHANGELOG.md2
-rw-r--r--actionpack/lib/action_controller/metal/data_streaming.rb1
-rw-r--r--actionpack/test/controller/send_file_test.rb12
3 files changed, 15 insertions, 0 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 64cd03859d..a8ac9081ec 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Accept symbols as #send_data :disposition value *Elia Schito*
+
* Add i18n scope to distance_of_time_in_words. *Steve Klabnik*
* `assert_template`:
diff --git a/actionpack/lib/action_controller/metal/data_streaming.rb b/actionpack/lib/action_controller/metal/data_streaming.rb
index 334943818c..75c4d3ef99 100644
--- a/actionpack/lib/action_controller/metal/data_streaming.rb
+++ b/actionpack/lib/action_controller/metal/data_streaming.rb
@@ -150,6 +150,7 @@ module ActionController #:nodoc:
disposition = options.fetch(:disposition, DEFAULT_SEND_FILE_DISPOSITION)
unless disposition.nil?
+ disposition = disposition.to_s
disposition += %(; filename="#{options[:filename]}") if options[:filename]
headers['Content-Disposition'] = disposition
end
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 8bf3096888..5e9053da5b 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -114,6 +114,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