diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-17 07:00:30 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-17 07:00:30 +0000 |
commit | 67bc801abcb0443f72583be05ba83748e1f1814a (patch) | |
tree | 7b76570dd16593a7d042258065e72b829ca54790 | |
parent | eb498a86acdec96eb2fdd3618b6e5ac30734ff39 (diff) | |
download | redmine-67bc801abcb0443f72583be05ba83748e1f1814a.tar.gz redmine-67bc801abcb0443f72583be05ba83748e1f1814a.zip |
attachment: add a functional test to show UTF-8 text file (#2371)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7823 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | test/fixtures/files/japanese-utf-8.txt | 1 | ||||
-rw-r--r-- | test/functional/attachments_controller_test.rb | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/fixtures/files/japanese-utf-8.txt b/test/fixtures/files/japanese-utf-8.txt new file mode 100644 index 000000000..c77dbef7f --- /dev/null +++ b/test/fixtures/files/japanese-utf-8.txt @@ -0,0 +1 @@ +日本語 diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 72a23efc4..514cc107a 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -71,6 +71,26 @@ class AttachmentsControllerTest < ActionController::TestCase assert_equal 'text/html', @response.content_type end + def test_show_text_file_utf_8 + a = Attachment.new(:container => Issue.find(1), + :file => uploaded_test_file("japanese-utf-8.txt", "text/plain"), + :author => User.find(1)) + assert a.save + assert_equal 'japanese-utf-8.txt', a.filename + + str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" + str_japanese.force_encoding('UTF-8') if str_japanese.respond_to?(:force_encoding) + + get :show, :id => a.id + assert_response :success + assert_template 'file' + assert_equal 'text/html', @response.content_type + assert_tag :tag => 'th', + :content => '1', + :attributes => { :class => 'line-num' }, + :sibling => { :tag => 'td', :content => /#{str_japanese}/ } + end + def test_show_text_file_should_send_if_too_big Setting.file_max_size_displayed = 512 Attachment.find(4).update_attribute :filesize, 754.kilobyte |