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
This commit is contained in:
Toshi MARUYAMA 2011-11-27 12:14:45 +00:00
parent a79e0fa5f6
commit d136672fa3
1 changed files with 45 additions and 0 deletions

View 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