##// END OF EJS Templates
add tests to export time entry csv in French for csv separator (#8368)...
Toshi MARUYAMA -
r7831:d136672fa37f
parent child
Show More
@@ -250,4 +250,49 class TimeEntryReportsControllerTest < ActionController::TestCase
250 end
250 end
251 assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1]
251 assert_equal "#{s2} #{user.lastname},7.30,7.30", lines[1]
252 end
252 end
253
254 def test_csv_fr
255 with_settings :default_language => "fr" do
256 str1 = "test_csv_fr"
257 user = User.find_by_id(3)
258 te1 = TimeEntry.create(:spent_on => '2011-11-11',
259 :hours => 7.3,
260 :project => Project.find(1),
261 :user => user,
262 :activity => TimeEntryActivity.find_by_name('Design'),
263 :comments => str1)
264
265 te2 = TimeEntry.find_by_comments(str1)
266 assert_not_nil te2
267 assert_equal 7.3, te2.hours
268 assert_equal 3, te2.user_id
269
270 get :report, :project_id => 1, :columns => 'day',
271 :from => "2011-11-11", :to => "2011-11-11",
272 :criterias => ["member"], :format => "csv"
273 assert_response :success
274 assert_equal 'text/csv', @response.content_type
275 lines = @response.body.chomp.split("\n")
276 # Headers
277 s1 = "Membre;2011-11-11;Total"
278 s2 = "Total"
279 if s1.respond_to?(:force_encoding)
280 s1.force_encoding('ISO-8859-1')
281 s2.force_encoding('ISO-8859-1')
282 end
283 assert_equal s1, lines.first
284 # Total row
285 assert_equal "#{user.firstname} #{user.lastname};7,30;7,30", lines[1]
286 assert_equal "#{s2};7,30;7,30", lines[2]
287
288 str_fr = "Fran\xc3\xa7ais"
289 if str_fr.respond_to?(:force_encoding)
290 str_fr.force_encoding('UTF-8')
291 end
292 assert_equal str_fr, l(:general_lang_name)
293 assert_equal 'ISO-8859-1', l(:general_csv_encoding)
294 assert_equal ';', l(:general_csv_separator)
295 assert_equal ',', l(:general_csv_decimal_separator)
296 end
297 end
253 end
298 end
General Comments 0
You need to be logged in to leave comments. Login now