summaryrefslogtreecommitdiffstats
path: root/test/functional/issues_controller_test.rb
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-11-16 15:36:26 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2011-11-16 15:36:26 +0000
commiteb498a86acdec96eb2fdd3618b6e5ac30734ff39 (patch)
tree39d51041ccd5619154fb93c3997c00d1927d07fd /test/functional/issues_controller_test.rb
parentdde0de8cc5c97ada01ab7f8b9e0b38de7f576ca2 (diff)
downloadredmine-eb498a86acdec96eb2fdd3618b6e5ac30734ff39.tar.gz
redmine-eb498a86acdec96eb2fdd3618b6e5ac30734ff39.zip
fix malformed issues csv encoding in case of unable to convert (#8549)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7822 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/issues_controller_test.rb')
-rw-r--r--test/functional/issues_controller_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index bdee16ead..b17e2aabe 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -324,6 +324,41 @@ class IssuesControllerTest < ActionController::TestCase
end
end
+ def test_index_csv_cannot_convert_should_be_replaced_big_5
+ with_settings :default_language => "zh-TW" do
+ str_utf8 = "\xe4\xbb\xa5\xe5\x86\x85"
+ if str_utf8.respond_to?(:force_encoding)
+ str_utf8.force_encoding('UTF-8')
+ end
+ issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3,
+ :status_id => 1, :priority => IssuePriority.all.first,
+ :subject => str_utf8)
+ assert issue.save
+
+ get :index, :project_id => 1,
+ :f => ['subject'],
+ :op => '=', :values => [str_utf8],
+ :format => 'csv'
+ assert_equal 'text/csv', @response.content_type
+ lines = @response.body.chomp.split("\n")
+ s1 = "\xaa\xac\xbaA"
+ if str_utf8.respond_to?(:force_encoding)
+ s1.force_encoding('Big5')
+ end
+ assert lines[0].include?(s1)
+ s2 = lines[1].split(",")[5]
+ if s1.respond_to?(:force_encoding)
+ s3 = "\xa5H?"
+ s3.force_encoding('Big5')
+ assert_equal s3, s2
+ elsif RUBY_PLATFORM == 'java'
+ assert_equal "??", s2
+ else
+ assert_equal "\xa5H???", s2
+ end
+ end
+ end
+
def test_index_pdf
get :index, :format => 'pdf'
assert_response :success