diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-03 13:12:51 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-03 13:12:51 -0300 |
commit | 62296a51c80b93fedcae896a534862687c8fef94 (patch) | |
tree | c6add8aa3802855b55ae3a45edfb2b1e20ea668d /actionpack/test/controller/send_file_test.rb | |
parent | 3de59e916d6a3d4eab202cf0c99b1f88905a3b43 (diff) | |
parent | 9b68877897a44d4484cde40117abc42c9b029154 (diff) | |
download | rails-62296a51c80b93fedcae896a534862687c8fef94.tar.gz rails-62296a51c80b93fedcae896a534862687c8fef94.tar.bz2 rails-62296a51c80b93fedcae896a534862687c8fef94.zip |
Merge commit 'rails/master'
Diffstat (limited to 'actionpack/test/controller/send_file_test.rb')
-rw-r--r-- | actionpack/test/controller/send_file_test.rb | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb index ae32ee5649..0afebac68c 100644 --- a/actionpack/test/controller/send_file_test.rb +++ b/actionpack/test/controller/send_file_test.rb @@ -1,9 +1,10 @@ +# encoding: utf-8 require 'abstract_unit' module TestFileUtils def file_name() File.basename(__FILE__) end def file_path() File.expand_path(__FILE__) end - def file_data() File.open(file_path, 'rb') { |f| f.read } end + def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end end class SendFileController < ActionController::Base @@ -22,6 +23,10 @@ class SendFileController < ActionController::Base def data send_data(file_data, options) end + + def multibyte_text_data + send_data("Кирилица\n祝您好運", options) + end end class SendFileTest < ActionController::TestCase @@ -55,6 +60,7 @@ class SendFileTest < ActionController::TestCase require 'stringio' output = StringIO.new output.binmode + output.string.force_encoding(file_data.encoding) if output.string.respond_to?(:force_encoding) assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } } assert_equal file_data, output.string end @@ -123,7 +129,7 @@ class SendFileTest < ActionController::TestCase # test overriding Cache-Control: no-cache header to fix IE open/save dialog @controller.headers = { 'Cache-Control' => 'no-cache' } @controller.send(:send_file_headers!, options) - h = @controller.headers + @controller.response.prepare! assert_equal 'private', h['Cache-Control'] end @@ -163,4 +169,11 @@ class SendFileTest < ActionController::TestCase assert_equal 200, @response.status end end + + def test_send_data_content_length_header + @controller.headers = {} + @controller.options = { :type => :text, :filename => 'file_with_utf8_text' } + process('multibyte_text_data') + assert_equal '29', @controller.headers['Content-Length'] + end end |