##// END OF EJS Templates
add functional test to export time entry report csv encoded in Big5 on Traditional Chinese locale (#8549)...
Toshi MARUYAMA -
r7691:95ef93104822
parent child
Show More
@@ -6,6 +6,10 class TimeEntryReportsControllerTest < ActionController::TestCase
6 :issues, :time_entries, :users, :trackers, :enumerations,
6 :issues, :time_entries, :users, :trackers, :enumerations,
7 :issue_statuses, :custom_fields, :custom_values
7 :issue_statuses, :custom_fields, :custom_values
8
8
9 def setup
10 Setting.default_language = "en"
11 end
12
9 def test_report_at_project_level
13 def test_report_at_project_level
10 get :report, :project_id => 'ecookbook'
14 get :report, :project_id => 'ecookbook'
11 assert_response :success
15 assert_response :success
@@ -143,4 +147,45 class TimeEntryReportsControllerTest < ActionController::TestCase
143 # Total row
147 # Total row
144 assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last
148 assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last
145 end
149 end
150
151 def test_csv_big_5
152 Setting.default_language = "zh-TW"
153 str_utf8 = "\xe4\xb8\x80\xe6\x9c\x88"
154 str_big5 = "\xa4@\xa4\xeb"
155 if str_utf8.respond_to?(:force_encoding)
156 str_utf8.force_encoding('UTF-8')
157 str_big5.force_encoding('Big5')
158 end
159 user = User.find_by_id(3)
160 user.firstname = str_utf8
161 user.lastname = "test-lastname"
162 assert user.save
163 comments = "test_csv_big_5"
164 te1 = TimeEntry.create(:spent_on => '2011-11-11',
165 :hours => 7.3,
166 :project => Project.find(1),
167 :user => user,
168 :activity => TimeEntryActivity.find_by_name('Design'),
169 :comments => comments)
170
171 te2 = TimeEntry.find_by_comments(comments)
172 assert_not_nil te2
173 assert_equal 7.3, te2.hours
174 assert_equal 3, te2.user_id
175
176 get :report, :project_id => 1, :columns => 'day',
177 :from => "2011-11-11", :to => "2011-11-11",
178 :criterias => ["member"], :format => "csv"
179 assert_response :success
180 assert_equal 'text/csv', @response.content_type
181 lines = @response.body.chomp.split("\n")
182 # Headers
183 s1 = "\xa6\xa8\xad\xfb,2011-11-11,\xc1`\xadp"
184 if s1.respond_to?(:force_encoding)
185 s1.force_encoding('Big5')
186 end
187 assert_equal s1, lines.first
188 # Total row
189 assert_equal "#{str_big5} #{user.lastname},7.30,7.30", lines[1]
190 end
146 end
191 end
General Comments 0
You need to be logged in to leave comments. Login now