]> source.dussan.org Git - redmine.git/commitdiff
add tests to export time entry csv in French for csv separator (#8368)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sun, 27 Nov 2011 12:14:45 +0000 (12:14 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Sun, 27 Nov 2011 12:14:45 +0000 (12:14 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7951 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/time_entry_reports_controller_test.rb

index 992ee7163d8da7a2fcd2b566d6a4e58cadc180e0..30ebe89d021d56d40742b723104d6b52f82324a7 100644 (file)
@@ -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