##// END OF EJS Templates
add tests to export time log csv in Traditional Chinese and French for csv separator (#8368)...
Toshi MARUYAMA -
r7824:caefb912b537
parent child
Show More
@@ -28,6 +28,8 class TimelogControllerTest < ActionController::TestCase
28 :trackers, :enumerations, :issue_statuses,
28 :trackers, :enumerations, :issue_statuses,
29 :custom_fields, :custom_values
29 :custom_fields, :custom_values
30
30
31 include Redmine::I18n
32
31 def setup
33 def setup
32 @controller = TimelogController.new
34 @controller = TimelogController.new
33 @request = ActionController::TestRequest.new
35 @request = ActionController::TestRequest.new
@@ -437,4 +439,72 class TimelogControllerTest < ActionController::TestCase
437 assert_equal "\xa5H???", s2
439 assert_equal "\xa5H???", s2
438 end
440 end
439 end
441 end
442
443 def test_csv_tw
444 with_settings :default_language => "zh-TW" do
445 str1 = "test_csv_tw"
446 user = User.find_by_id(3)
447 te1 = TimeEntry.create(:spent_on => '2011-11-10',
448 :hours => 999.9,
449 :project => Project.find(1),
450 :user => user,
451 :activity => TimeEntryActivity.find_by_name('Design'),
452 :comments => str1)
453 te2 = TimeEntry.find_by_comments(str1)
454 assert_not_nil te2
455 assert_equal 999.9, te2.hours
456 assert_equal 3, te2.user_id
457
458 get :index, :project_id => 1, :format => 'csv',
459 :from => '2011-11-10', :to => '2011-11-10'
460 assert_response :success
461 assert_equal 'text/csv', @response.content_type
462
463 ar = @response.body.chomp.split("\n")
464 s2 = ar[1].split(",")[7]
465 assert_equal '999.9', s2
466
467 str_tw = "Traditional Chinese (\xe7\xb9\x81\xe9\xab\x94\xe4\xb8\xad\xe6\x96\x87)"
468 if str_tw.respond_to?(:force_encoding)
469 str_tw.force_encoding('UTF-8')
470 end
471 assert_equal str_tw, l(:general_lang_name)
472 assert_equal ',', l(:general_csv_separator)
473 assert_equal '.', l(:general_csv_decimal_separator)
474 end
475 end
476
477 def test_csv_fr
478 with_settings :default_language => "fr" do
479 str1 = "test_csv_fr"
480 user = User.find_by_id(3)
481 te1 = TimeEntry.create(:spent_on => '2011-11-10',
482 :hours => 999.9,
483 :project => Project.find(1),
484 :user => user,
485 :activity => TimeEntryActivity.find_by_name('Design'),
486 :comments => str1)
487 te2 = TimeEntry.find_by_comments(str1)
488 assert_not_nil te2
489 assert_equal 999.9, te2.hours
490 assert_equal 3, te2.user_id
491
492 get :index, :project_id => 1, :format => 'csv',
493 :from => '2011-11-10', :to => '2011-11-10'
494 assert_response :success
495 assert_equal 'text/csv', @response.content_type
496
497 ar = @response.body.chomp.split("\n")
498 s2 = ar[1].split(";")[7]
499 assert_equal '999,9', s2
500
501 str_fr = "Fran\xc3\xa7ais"
502 if str_fr.respond_to?(:force_encoding)
503 str_fr.force_encoding('UTF-8')
504 end
505 assert_equal str_fr, l(:general_lang_name)
506 assert_equal ';', l(:general_csv_separator)
507 assert_equal ',', l(:general_csv_decimal_separator)
508 end
509 end
440 end
510 end
General Comments 0
You need to be logged in to leave comments. Login now