##// END OF EJS Templates
remove trailing white-spaces from test/functional/timelog_controller_test.rb....
Toshi MARUYAMA -
r6504:f4eb05a26ecb
parent child
Show More
@@ -1,330 +1,329
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 # redMine - project management software
2 # Redmine - project management software
3 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 # Copyright (C) 2006-2011 Jean-Philippe Lang
4 #
4 #
5 # This program is free software; you can redistribute it and/or
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
8 # of the License, or (at your option) any later version.
9 #
9 #
10 # This program is distributed in the hope that it will be useful,
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
13 # GNU General Public License for more details.
14 #
14 #
15 # You should have received a copy of the GNU General Public License
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
18
19 require File.expand_path('../../test_helper', __FILE__)
19 require File.expand_path('../../test_helper', __FILE__)
20 require 'timelog_controller'
20 require 'timelog_controller'
21
21
22 # Re-raise errors caught by the controller.
22 # Re-raise errors caught by the controller.
23 class TimelogController; def rescue_action(e) raise e end; end
23 class TimelogController; def rescue_action(e) raise e end; end
24
24
25 class TimelogControllerTest < ActionController::TestCase
25 class TimelogControllerTest < ActionController::TestCase
26 fixtures :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values
26 fixtures :projects, :enabled_modules, :roles, :members, :member_roles, :issues, :time_entries, :users, :trackers, :enumerations, :issue_statuses, :custom_fields, :custom_values
27
27
28 def setup
28 def setup
29 @controller = TimelogController.new
29 @controller = TimelogController.new
30 @request = ActionController::TestRequest.new
30 @request = ActionController::TestRequest.new
31 @response = ActionController::TestResponse.new
31 @response = ActionController::TestResponse.new
32 end
32 end
33
33
34 def test_get_new
34 def test_get_new
35 @request.session[:user_id] = 3
35 @request.session[:user_id] = 3
36 get :new, :project_id => 1
36 get :new, :project_id => 1
37 assert_response :success
37 assert_response :success
38 assert_template 'edit'
38 assert_template 'edit'
39 # Default activity selected
39 # Default activity selected
40 assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
40 assert_tag :tag => 'option', :attributes => { :selected => 'selected' },
41 :content => 'Development'
41 :content => 'Development'
42 end
42 end
43
43
44 def test_get_new_should_only_show_active_time_entry_activities
44 def test_get_new_should_only_show_active_time_entry_activities
45 @request.session[:user_id] = 3
45 @request.session[:user_id] = 3
46 get :new, :project_id => 1
46 get :new, :project_id => 1
47 assert_response :success
47 assert_response :success
48 assert_template 'edit'
48 assert_template 'edit'
49 assert_no_tag :tag => 'option', :content => 'Inactive Activity'
49 assert_no_tag :tag => 'option', :content => 'Inactive Activity'
50
51 end
50 end
52
51
53 def test_get_edit_existing_time
52 def test_get_edit_existing_time
54 @request.session[:user_id] = 2
53 @request.session[:user_id] = 2
55 get :edit, :id => 2, :project_id => nil
54 get :edit, :id => 2, :project_id => nil
56 assert_response :success
55 assert_response :success
57 assert_template 'edit'
56 assert_template 'edit'
58 # Default activity selected
57 # Default activity selected
59 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' }
58 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' }
60 end
59 end
61
60
62 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
61 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
63 te = TimeEntry.find(1)
62 te = TimeEntry.find(1)
64 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
63 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
65 te.save!
64 te.save!
66
65
67 @request.session[:user_id] = 1
66 @request.session[:user_id] = 1
68 get :edit, :project_id => 1, :id => 1
67 get :edit, :project_id => 1, :id => 1
69 assert_response :success
68 assert_response :success
70 assert_template 'edit'
69 assert_template 'edit'
71 # Blank option since nothing is pre-selected
70 # Blank option since nothing is pre-selected
72 assert_tag :tag => 'option', :content => '--- Please select ---'
71 assert_tag :tag => 'option', :content => '--- Please select ---'
73 end
72 end
74
73
75 def test_post_create
74 def test_post_create
76 # TODO: should POST to issues’ time log instead of project. change form
75 # TODO: should POST to issues’ time log instead of project. change form
77 # and routing
76 # and routing
78 @request.session[:user_id] = 3
77 @request.session[:user_id] = 3
79 post :create, :project_id => 1,
78 post :create, :project_id => 1,
80 :time_entry => {:comments => 'Some work on TimelogControllerTest',
79 :time_entry => {:comments => 'Some work on TimelogControllerTest',
81 # Not the default activity
80 # Not the default activity
82 :activity_id => '11',
81 :activity_id => '11',
83 :spent_on => '2008-03-14',
82 :spent_on => '2008-03-14',
84 :issue_id => '1',
83 :issue_id => '1',
85 :hours => '7.3'}
84 :hours => '7.3'}
86 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
85 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
87
86
88 i = Issue.find(1)
87 i = Issue.find(1)
89 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
88 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
90 assert_not_nil t
89 assert_not_nil t
91 assert_equal 11, t.activity_id
90 assert_equal 11, t.activity_id
92 assert_equal 7.3, t.hours
91 assert_equal 7.3, t.hours
93 assert_equal 3, t.user_id
92 assert_equal 3, t.user_id
94 assert_equal i, t.issue
93 assert_equal i, t.issue
95 assert_equal i.project, t.project
94 assert_equal i.project, t.project
96 end
95 end
97
96
98 def test_post_create_with_blank_issue
97 def test_post_create_with_blank_issue
99 # TODO: should POST to issues’ time log instead of project. change form
98 # TODO: should POST to issues’ time log instead of project. change form
100 # and routing
99 # and routing
101 @request.session[:user_id] = 3
100 @request.session[:user_id] = 3
102 post :create, :project_id => 1,
101 post :create, :project_id => 1,
103 :time_entry => {:comments => 'Some work on TimelogControllerTest',
102 :time_entry => {:comments => 'Some work on TimelogControllerTest',
104 # Not the default activity
103 # Not the default activity
105 :activity_id => '11',
104 :activity_id => '11',
106 :issue_id => '',
105 :issue_id => '',
107 :spent_on => '2008-03-14',
106 :spent_on => '2008-03-14',
108 :hours => '7.3'}
107 :hours => '7.3'}
109 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
108 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
110
109
111 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
110 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
112 assert_not_nil t
111 assert_not_nil t
113 assert_equal 11, t.activity_id
112 assert_equal 11, t.activity_id
114 assert_equal 7.3, t.hours
113 assert_equal 7.3, t.hours
115 assert_equal 3, t.user_id
114 assert_equal 3, t.user_id
116 end
115 end
117
116
118 def test_update
117 def test_update
119 entry = TimeEntry.find(1)
118 entry = TimeEntry.find(1)
120 assert_equal 1, entry.issue_id
119 assert_equal 1, entry.issue_id
121 assert_equal 2, entry.user_id
120 assert_equal 2, entry.user_id
122
121
123 @request.session[:user_id] = 1
122 @request.session[:user_id] = 1
124 put :update, :id => 1,
123 put :update, :id => 1,
125 :time_entry => {:issue_id => '2',
124 :time_entry => {:issue_id => '2',
126 :hours => '8'}
125 :hours => '8'}
127 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
126 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
128 entry.reload
127 entry.reload
129
128
130 assert_equal 8, entry.hours
129 assert_equal 8, entry.hours
131 assert_equal 2, entry.issue_id
130 assert_equal 2, entry.issue_id
132 assert_equal 2, entry.user_id
131 assert_equal 2, entry.user_id
133 end
132 end
134
133
135 def test_get_bulk_edit
134 def test_get_bulk_edit
136 @request.session[:user_id] = 2
135 @request.session[:user_id] = 2
137 get :bulk_edit, :ids => [1, 2]
136 get :bulk_edit, :ids => [1, 2]
138 assert_response :success
137 assert_response :success
139 assert_template 'bulk_edit'
138 assert_template 'bulk_edit'
140
139
141 # System wide custom field
140 # System wide custom field
142 assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'}
141 assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'}
143 end
142 end
144
143
145 def test_get_bulk_edit_on_different_projects
144 def test_get_bulk_edit_on_different_projects
146 @request.session[:user_id] = 2
145 @request.session[:user_id] = 2
147 get :bulk_edit, :ids => [1, 2, 6]
146 get :bulk_edit, :ids => [1, 2, 6]
148 assert_response :success
147 assert_response :success
149 assert_template 'bulk_edit'
148 assert_template 'bulk_edit'
150 end
149 end
151
150
152 def test_bulk_update
151 def test_bulk_update
153 @request.session[:user_id] = 2
152 @request.session[:user_id] = 2
154 # update time entry activity
153 # update time entry activity
155 post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9}
154 post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9}
156
155
157 assert_response 302
156 assert_response 302
158 # check that the issues were updated
157 # check that the issues were updated
159 assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id}
158 assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id}
160 end
159 end
161
160
162 def test_bulk_update_on_different_projects
161 def test_bulk_update_on_different_projects
163 @request.session[:user_id] = 2
162 @request.session[:user_id] = 2
164 # update time entry activity
163 # update time entry activity
165 post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 }
164 post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 }
166
165
167 assert_response 302
166 assert_response 302
168 # check that the issues were updated
167 # check that the issues were updated
169 assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id}
168 assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id}
170 end
169 end
171
170
172 def test_bulk_update_on_different_projects_without_rights
171 def test_bulk_update_on_different_projects_without_rights
173 @request.session[:user_id] = 3
172 @request.session[:user_id] = 3
174 user = User.find(3)
173 user = User.find(3)
175 action = { :controller => "timelog", :action => "bulk_update" }
174 action = { :controller => "timelog", :action => "bulk_update" }
176 assert user.allowed_to?(action, TimeEntry.find(1).project)
175 assert user.allowed_to?(action, TimeEntry.find(1).project)
177 assert ! user.allowed_to?(action, TimeEntry.find(5).project)
176 assert ! user.allowed_to?(action, TimeEntry.find(5).project)
178 post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 }
177 post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 }
179 assert_response 403
178 assert_response 403
180 end
179 end
181
180
182 def test_bulk_update_custom_field
181 def test_bulk_update_custom_field
183 @request.session[:user_id] = 2
182 @request.session[:user_id] = 2
184 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }
183 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }
185
184
186 assert_response 302
185 assert_response 302
187 assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value}
186 assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value}
188 end
187 end
189
188
190 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
189 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
191 @request.session[:user_id] = 2
190 @request.session[:user_id] = 2
192 post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
191 post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
193
192
194 assert_response :redirect
193 assert_response :redirect
195 assert_redirected_to '/time_entries'
194 assert_redirected_to '/time_entries'
196 end
195 end
197
196
198 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
197 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
199 @request.session[:user_id] = 2
198 @request.session[:user_id] = 2
200 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
199 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
201
200
202 assert_response :redirect
201 assert_response :redirect
203 assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier
202 assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier
204 end
203 end
205
204
206 def test_destroy
205 def test_destroy
207 @request.session[:user_id] = 2
206 @request.session[:user_id] = 2
208 delete :destroy, :id => 1
207 delete :destroy, :id => 1
209 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
208 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
210 assert_equal I18n.t(:notice_successful_delete), flash[:notice]
209 assert_equal I18n.t(:notice_successful_delete), flash[:notice]
211 assert_nil TimeEntry.find_by_id(1)
210 assert_nil TimeEntry.find_by_id(1)
212 end
211 end
213
212
214 def test_destroy_should_fail
213 def test_destroy_should_fail
215 # simulate that this fails (e.g. due to a plugin), see #5700
214 # simulate that this fails (e.g. due to a plugin), see #5700
216 TimeEntry.any_instance.expects(:destroy).returns(false)
215 TimeEntry.any_instance.expects(:destroy).returns(false)
217
216
218 @request.session[:user_id] = 2
217 @request.session[:user_id] = 2
219 delete :destroy, :id => 1
218 delete :destroy, :id => 1
220 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
219 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
221 assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
220 assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
222 assert_not_nil TimeEntry.find_by_id(1)
221 assert_not_nil TimeEntry.find_by_id(1)
223 end
222 end
224
223
225 def test_index_all_projects
224 def test_index_all_projects
226 get :index
225 get :index
227 assert_response :success
226 assert_response :success
228 assert_template 'index'
227 assert_template 'index'
229 assert_not_nil assigns(:total_hours)
228 assert_not_nil assigns(:total_hours)
230 assert_equal "162.90", "%.2f" % assigns(:total_hours)
229 assert_equal "162.90", "%.2f" % assigns(:total_hours)
231 assert_tag :form,
230 assert_tag :form,
232 :attributes => {:action => "/time_entries", :id => 'query_form'}
231 :attributes => {:action => "/time_entries", :id => 'query_form'}
233 end
232 end
234
233
235 def test_index_at_project_level
234 def test_index_at_project_level
236 get :index, :project_id => 'ecookbook'
235 get :index, :project_id => 'ecookbook'
237 assert_response :success
236 assert_response :success
238 assert_template 'index'
237 assert_template 'index'
239 assert_not_nil assigns(:entries)
238 assert_not_nil assigns(:entries)
240 assert_equal 4, assigns(:entries).size
239 assert_equal 4, assigns(:entries).size
241 # project and subproject
240 # project and subproject
242 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
241 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
243 assert_not_nil assigns(:total_hours)
242 assert_not_nil assigns(:total_hours)
244 assert_equal "162.90", "%.2f" % assigns(:total_hours)
243 assert_equal "162.90", "%.2f" % assigns(:total_hours)
245 # display all time by default
244 # display all time by default
246 assert_equal '2007-03-12'.to_date, assigns(:from)
245 assert_equal '2007-03-12'.to_date, assigns(:from)
247 assert_equal '2007-04-22'.to_date, assigns(:to)
246 assert_equal '2007-04-22'.to_date, assigns(:to)
248 assert_tag :form,
247 assert_tag :form,
249 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
248 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
250 end
249 end
251
250
252 def test_index_at_project_level_with_date_range
251 def test_index_at_project_level_with_date_range
253 get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30'
252 get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30'
254 assert_response :success
253 assert_response :success
255 assert_template 'index'
254 assert_template 'index'
256 assert_not_nil assigns(:entries)
255 assert_not_nil assigns(:entries)
257 assert_equal 3, assigns(:entries).size
256 assert_equal 3, assigns(:entries).size
258 assert_not_nil assigns(:total_hours)
257 assert_not_nil assigns(:total_hours)
259 assert_equal "12.90", "%.2f" % assigns(:total_hours)
258 assert_equal "12.90", "%.2f" % assigns(:total_hours)
260 assert_equal '2007-03-20'.to_date, assigns(:from)
259 assert_equal '2007-03-20'.to_date, assigns(:from)
261 assert_equal '2007-04-30'.to_date, assigns(:to)
260 assert_equal '2007-04-30'.to_date, assigns(:to)
262 assert_tag :form,
261 assert_tag :form,
263 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
262 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
264 end
263 end
265
264
266 def test_index_at_project_level_with_period
265 def test_index_at_project_level_with_period
267 get :index, :project_id => 'ecookbook', :period => '7_days'
266 get :index, :project_id => 'ecookbook', :period => '7_days'
268 assert_response :success
267 assert_response :success
269 assert_template 'index'
268 assert_template 'index'
270 assert_not_nil assigns(:entries)
269 assert_not_nil assigns(:entries)
271 assert_not_nil assigns(:total_hours)
270 assert_not_nil assigns(:total_hours)
272 assert_equal Date.today - 7, assigns(:from)
271 assert_equal Date.today - 7, assigns(:from)
273 assert_equal Date.today, assigns(:to)
272 assert_equal Date.today, assigns(:to)
274 assert_tag :form,
273 assert_tag :form,
275 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
274 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
276 end
275 end
277
276
278 def test_index_one_day
277 def test_index_one_day
279 get :index, :project_id => 'ecookbook', :from => "2007-03-23", :to => "2007-03-23"
278 get :index, :project_id => 'ecookbook', :from => "2007-03-23", :to => "2007-03-23"
280 assert_response :success
279 assert_response :success
281 assert_template 'index'
280 assert_template 'index'
282 assert_not_nil assigns(:total_hours)
281 assert_not_nil assigns(:total_hours)
283 assert_equal "4.25", "%.2f" % assigns(:total_hours)
282 assert_equal "4.25", "%.2f" % assigns(:total_hours)
284 assert_tag :form,
283 assert_tag :form,
285 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
284 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
286 end
285 end
287
286
288 def test_index_at_issue_level
287 def test_index_at_issue_level
289 get :index, :issue_id => 1
288 get :index, :issue_id => 1
290 assert_response :success
289 assert_response :success
291 assert_template 'index'
290 assert_template 'index'
292 assert_not_nil assigns(:entries)
291 assert_not_nil assigns(:entries)
293 assert_equal 2, assigns(:entries).size
292 assert_equal 2, assigns(:entries).size
294 assert_not_nil assigns(:total_hours)
293 assert_not_nil assigns(:total_hours)
295 assert_equal 154.25, assigns(:total_hours)
294 assert_equal 154.25, assigns(:total_hours)
296 # display all time based on what's been logged
295 # display all time based on what's been logged
297 assert_equal '2007-03-12'.to_date, assigns(:from)
296 assert_equal '2007-03-12'.to_date, assigns(:from)
298 assert_equal '2007-04-22'.to_date, assigns(:to)
297 assert_equal '2007-04-22'.to_date, assigns(:to)
299 # TODO: remove /projects/:project_id/issues/:issue_id/time_entries routes
298 # TODO: remove /projects/:project_id/issues/:issue_id/time_entries routes
300 # to use /issues/:issue_id/time_entries
299 # to use /issues/:issue_id/time_entries
301 assert_tag :form,
300 assert_tag :form,
302 :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'}
301 :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'}
303 end
302 end
304
303
305 def test_index_atom_feed
304 def test_index_atom_feed
306 get :index, :project_id => 1, :format => 'atom'
305 get :index, :project_id => 1, :format => 'atom'
307 assert_response :success
306 assert_response :success
308 assert_equal 'application/atom+xml', @response.content_type
307 assert_equal 'application/atom+xml', @response.content_type
309 assert_not_nil assigns(:items)
308 assert_not_nil assigns(:items)
310 assert assigns(:items).first.is_a?(TimeEntry)
309 assert assigns(:items).first.is_a?(TimeEntry)
311 end
310 end
312
311
313 def test_index_all_projects_csv_export
312 def test_index_all_projects_csv_export
314 Setting.date_format = '%m/%d/%Y'
313 Setting.date_format = '%m/%d/%Y'
315 get :index, :format => 'csv'
314 get :index, :format => 'csv'
316 assert_response :success
315 assert_response :success
317 assert_equal 'text/csv', @response.content_type
316 assert_equal 'text/csv', @response.content_type
318 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
317 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
319 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
318 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
320 end
319 end
321
320
322 def test_index_csv_export
321 def test_index_csv_export
323 Setting.date_format = '%m/%d/%Y'
322 Setting.date_format = '%m/%d/%Y'
324 get :index, :project_id => 1, :format => 'csv'
323 get :index, :project_id => 1, :format => 'csv'
325 assert_response :success
324 assert_response :success
326 assert_equal 'text/csv', @response.content_type
325 assert_equal 'text/csv', @response.content_type
327 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
326 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
328 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
327 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
329 end
328 end
330 end
329 end
General Comments 0
You need to be logged in to leave comments. Login now