From: Toshi MARUYAMA Date: Tue, 15 Nov 2011 10:06:01 +0000 (+0000) Subject: add functional test to export time log csv encoded in Big5 on Traditional Chinese... X-Git-Tag: 1.3.0~199 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=36afbc41b61ce3a95b004bc1ae4a93cd415cb28d;p=redmine.git add functional test to export time log csv encoded in Big5 on Traditional Chinese locale (#8549) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7812 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index e8e6388a7..6581d5bc3 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -329,4 +329,43 @@ class TimelogControllerTest < ActionController::TestCase assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n") assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n") end + + def test_csv_big_5 + user = User.find_by_id(3) + user.language = "zh-TW" + assert user.save + str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88" + str_big5 = "\xa4@\xa4\xeb" + if str_utf8.respond_to?(:force_encoding) + str_utf8.force_encoding('UTF-8') + str_big5.force_encoding('Big5') + end + @request.session[:user_id] = 3 + post :create, :project_id => 1, + :time_entry => {:comments => str_utf8, + # Not the default activity + :activity_id => '11', + :issue_id => '', + :spent_on => '2011-11-10', + :hours => '7.3'} + assert_redirected_to :action => 'index', :project_id => 'ecookbook' + + t = TimeEntry.find_by_comments(str_utf8) + assert_not_nil t + assert_equal 11, t.activity_id + assert_equal 7.3, t.hours + assert_equal 3, t.user_id + + get :index, :project_id => 1, :format => 'csv', + :from => '2011-11-10', :to => '2011-11-10' + assert_response :success + assert_equal 'text/csv', @response.content_type + ar = @response.body.chomp.split("\n") + s1 = "\xa4\xe9\xb4\xc1" + if str_utf8.respond_to?(:force_encoding) + s1.force_encoding('Big5') + end + assert ar[0].include?(s1) + assert ar[1].include?(str_big5) + end end