diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-27 10:02:31 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-11-27 10:02:31 +0000 |
commit | caefb912b537d4084917ad4c7164d85bb5a19fc9 (patch) | |
tree | 11e7496731d9579d18a0ac7c4a53d9aeb8975e21 /test | |
parent | 0eed9198eb3e9b956a1cb1df112aac4e055fe3e3 (diff) | |
download | redmine-caefb912b537d4084917ad4c7164d85bb5a19fc9.tar.gz redmine-caefb912b537d4084917ad4c7164d85bb5a19fc9.zip |
add tests to export time log csv in Traditional Chinese and French for csv separator (#8368)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7944 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/timelog_controller_test.rb | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/functional/timelog_controller_test.rb b/test/functional/timelog_controller_test.rb index ce06852f8..fe2aea6e3 100644 --- a/test/functional/timelog_controller_test.rb +++ b/test/functional/timelog_controller_test.rb @@ -28,6 +28,8 @@ class TimelogControllerTest < ActionController::TestCase :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values + include Redmine::I18n + def setup @controller = TimelogController.new @request = ActionController::TestRequest.new @@ -437,4 +439,72 @@ class TimelogControllerTest < ActionController::TestCase assert_equal "\xa5H???", s2 end end + + def test_csv_tw + with_settings :default_language => "zh-TW" do + str1 = "test_csv_tw" + user = User.find_by_id(3) + te1 = TimeEntry.create(:spent_on => '2011-11-10', + :hours => 999.9, + :project => Project.find(1), + :user => user, + :activity => TimeEntryActivity.find_by_name('Design'), + :comments => str1) + te2 = TimeEntry.find_by_comments(str1) + assert_not_nil te2 + assert_equal 999.9, te2.hours + assert_equal 3, te2.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") + s2 = ar[1].split(",")[7] + assert_equal '999.9', s2 + + str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)" + if str_tw.respond_to?(:force_encoding) + str_tw.force_encoding('UTF-8') + end + assert_equal str_tw, l(:general_lang_name) + assert_equal ',', l(:general_csv_separator) + assert_equal '.', l(:general_csv_decimal_separator) + end + end + + def test_csv_fr + with_settings :default_language => "fr" do + str1 = "test_csv_fr" + user = User.find_by_id(3) + te1 = TimeEntry.create(:spent_on => '2011-11-10', + :hours => 999.9, + :project => Project.find(1), + :user => user, + :activity => TimeEntryActivity.find_by_name('Design'), + :comments => str1) + te2 = TimeEntry.find_by_comments(str1) + assert_not_nil te2 + assert_equal 999.9, te2.hours + assert_equal 3, te2.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") + s2 = ar[1].split(";")[7] + assert_equal '999,9', s2 + + str_fr = "Fran\xc3\xa7ais" + if str_fr.respond_to?(:force_encoding) + str_fr.force_encoding('UTF-8') + end + assert_equal str_fr, l(:general_lang_name) + assert_equal ';', l(:general_csv_separator) + assert_equal ',', l(:general_csv_decimal_separator) + end + end end |