aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-13 13:29:49 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-13 13:29:49 +0000
commit96e54780b34ea6e8d8f972ff1f0b305aee44430c (patch)
treeb0891fd894681dee07f29b61808c8349c619845c /actionpack/test
parent5f5b053ce879f9a01c04cfe0d6c0600b80979dfe (diff)
downloadrails-96e54780b34ea6e8d8f972ff1f0b305aee44430c.tar.gz
rails-96e54780b34ea6e8d8f972ff1f0b305aee44430c.tar.bz2
rails-96e54780b34ea6e8d8f972ff1f0b305aee44430c.zip
Fixed that send_file would "remember" all the files sent by adding to the headers again and again #458 [bitsweat]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@400 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/controller/send_file_test.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 57205a01c5..d18d15b18a 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -65,4 +65,28 @@ class SendFileTest < Test::Unit::TestCase
assert_kind_of String, response.body
assert_equal file_data, response.body
end
+
+ # Test that send_file_headers! is setting the correct HTTP headers.
+ def test_send_file_headers!
+ options = {
+ :length => 1,
+ :type => 'type',
+ :disposition => 'disposition',
+ :filename => 'filename'
+ }
+
+ # Do it a few times: the resulting headers should be identical
+ # no matter how many times you send with the same options.
+ # Test resolving Ticket #458.
+ @controller.headers = {}
+ @controller.send(:send_file_headers!, options)
+ @controller.send(:send_file_headers!, options)
+ @controller.send(:send_file_headers!, options)
+
+ h = @controller.headers
+ assert_equal 1, h['Content-Length']
+ assert_equal 'type', h['Content-Type']
+ assert_equal 'disposition; filename="filename"', h['Content-Disposition']
+ assert_equal 'binary', h['Content-Transfer-Encoding']
+ end
end