From d136672fa37fbd1a6f2b4c06f60e831438ff1392 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Sun, 27 Nov 2011 12:14:45 +0000 Subject: [PATCH] add tests to export time entry csv in French for csv separator (#8368) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7951 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../time_entry_reports_controller_test.rb | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/functional/time_entry_reports_controller_test.rb b/test/functional/time_entry_reports_controller_test.rb index 992ee7163..30ebe89d0 100644 --- a/test/functional/time_entry_reports_controller_test.rb +++ b/test/functional/time_entry_reports_controller_test.rb @@ -250,4 +250,49 @@ class TimeEntryReportsControllerTest < ActionController::TestCase end assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1] 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-11', + :hours => 7.3, + :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 7.3, te2.hours + assert_equal 3, te2.user_id + + get :report, :project_id => 1, :columns => 'day', + :from => "2011-11-11", :to => "2011-11-11", + :criterias => ["member"], :format => "csv" + assert_response :success + assert_equal 'text/csv', @response.content_type + lines = @response.body.chomp.split("\n") + # Headers + s1 = "Membre;2011-11-11;Total" + s2 = "Total" + if s1.respond_to?(:force_encoding) + s1.force_encoding('ISO-8859-1') + s2.force_encoding('ISO-8859-1') + end + assert_equal s1, lines.first + # Total row + assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1] + assert_equal "#{s2};7,30;7,30", lines[2] + + 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 'ISO-8859-1', l(:general_csv_encoding) + assert_equal ';', l(:general_csv_separator) + assert_equal ',', l(:general_csv_decimal_separator) + end + end end -- 2.39.5