##// END OF EJS Templates
Code cleanup....
Jean-Philippe Lang -
r5199:1af6527e427b
parent child
Show More
@@ -1,336 +1,330
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-2007 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
50
51 end
51 end
52
52
53 def test_get_edit_existing_time
53 def test_get_edit_existing_time
54 @request.session[:user_id] = 2
54 @request.session[:user_id] = 2
55 get :edit, :id => 2, :project_id => nil
55 get :edit, :id => 2, :project_id => nil
56 assert_response :success
56 assert_response :success
57 assert_template 'edit'
57 assert_template 'edit'
58 # Default activity selected
58 # Default activity selected
59 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' }
59 assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' }
60 end
60 end
61
61
62 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
62 def test_get_edit_with_an_existing_time_entry_with_inactive_activity
63 te = TimeEntry.find(1)
63 te = TimeEntry.find(1)
64 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
64 te.activity = TimeEntryActivity.find_by_name("Inactive Activity")
65 te.save!
65 te.save!
66
66
67 @request.session[:user_id] = 1
67 @request.session[:user_id] = 1
68 get :edit, :project_id => 1, :id => 1
68 get :edit, :project_id => 1, :id => 1
69 assert_response :success
69 assert_response :success
70 assert_template 'edit'
70 assert_template 'edit'
71 # Blank option since nothing is pre-selected
71 # Blank option since nothing is pre-selected
72 assert_tag :tag => 'option', :content => '--- Please select ---'
72 assert_tag :tag => 'option', :content => '--- Please select ---'
73 end
73 end
74
74
75 def test_post_create
75 def test_post_create
76 # TODO: should POST to issues’ time log instead of project. change form
76 # TODO: should POST to issues’ time log instead of project. change form
77 # and routing
77 # and routing
78 @request.session[:user_id] = 3
78 @request.session[:user_id] = 3
79 post :create, :project_id => 1,
79 post :create, :project_id => 1,
80 :time_entry => {:comments => 'Some work on TimelogControllerTest',
80 :time_entry => {:comments => 'Some work on TimelogControllerTest',
81 # Not the default activity
81 # Not the default activity
82 :activity_id => '11',
82 :activity_id => '11',
83 :spent_on => '2008-03-14',
83 :spent_on => '2008-03-14',
84 :issue_id => '1',
84 :issue_id => '1',
85 :hours => '7.3'}
85 :hours => '7.3'}
86 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
86 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
87
87
88 i = Issue.find(1)
88 i = Issue.find(1)
89 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
89 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
90 assert_not_nil t
90 assert_not_nil t
91 assert_equal 11, t.activity_id
91 assert_equal 11, t.activity_id
92 assert_equal 7.3, t.hours
92 assert_equal 7.3, t.hours
93 assert_equal 3, t.user_id
93 assert_equal 3, t.user_id
94 assert_equal i, t.issue
94 assert_equal i, t.issue
95 assert_equal i.project, t.project
95 assert_equal i.project, t.project
96 end
96 end
97
97
98 def test_post_create_with_blank_issue
98 def test_post_create_with_blank_issue
99 # TODO: should POST to issues’ time log instead of project. change form
99 # TODO: should POST to issues’ time log instead of project. change form
100 # and routing
100 # and routing
101 @request.session[:user_id] = 3
101 @request.session[:user_id] = 3
102 post :create, :project_id => 1,
102 post :create, :project_id => 1,
103 :time_entry => {:comments => 'Some work on TimelogControllerTest',
103 :time_entry => {:comments => 'Some work on TimelogControllerTest',
104 # Not the default activity
104 # Not the default activity
105 :activity_id => '11',
105 :activity_id => '11',
106 :issue_id => '',
106 :issue_id => '',
107 :spent_on => '2008-03-14',
107 :spent_on => '2008-03-14',
108 :hours => '7.3'}
108 :hours => '7.3'}
109 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
109 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
110
110
111 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
111 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
112 assert_not_nil t
112 assert_not_nil t
113 assert_equal 11, t.activity_id
113 assert_equal 11, t.activity_id
114 assert_equal 7.3, t.hours
114 assert_equal 7.3, t.hours
115 assert_equal 3, t.user_id
115 assert_equal 3, t.user_id
116 end
116 end
117
117
118 def test_update
118 def test_update
119 entry = TimeEntry.find(1)
119 entry = TimeEntry.find(1)
120 assert_equal 1, entry.issue_id
120 assert_equal 1, entry.issue_id
121 assert_equal 2, entry.user_id
121 assert_equal 2, entry.user_id
122
122
123 @request.session[:user_id] = 1
123 @request.session[:user_id] = 1
124 put :update, :id => 1,
124 put :update, :id => 1,
125 :time_entry => {:issue_id => '2',
125 :time_entry => {:issue_id => '2',
126 :hours => '8'}
126 :hours => '8'}
127 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
127 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
128 entry.reload
128 entry.reload
129
129
130 assert_equal 8, entry.hours
130 assert_equal 8, entry.hours
131 assert_equal 2, entry.issue_id
131 assert_equal 2, entry.issue_id
132 assert_equal 2, entry.user_id
132 assert_equal 2, entry.user_id
133 end
133 end
134
134
135 def test_get_bulk_edit
135 def test_get_bulk_edit
136 @request.session[:user_id] = 2
136 @request.session[:user_id] = 2
137 get :bulk_edit, :ids => [1, 2]
137 get :bulk_edit, :ids => [1, 2]
138 assert_response :success
138 assert_response :success
139 assert_template 'bulk_edit'
139 assert_template 'bulk_edit'
140
140
141 # System wide custom field
141 # System wide custom field
142 assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'}
142 assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'}
143 end
143 end
144
144
145 def test_get_bulk_edit_on_different_projects
145 def test_get_bulk_edit_on_different_projects
146 @request.session[:user_id] = 2
146 @request.session[:user_id] = 2
147 get :bulk_edit, :ids => [1, 2, 6]
147 get :bulk_edit, :ids => [1, 2, 6]
148 assert_response :success
148 assert_response :success
149 assert_template 'bulk_edit'
149 assert_template 'bulk_edit'
150 end
150 end
151
151
152 def test_bulk_update
152 def test_bulk_update
153 @request.session[:user_id] = 2
153 @request.session[:user_id] = 2
154 # update time entry activity
154 # update time entry activity
155 post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9}
155 post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9}
156
156
157 assert_response 302
157 assert_response 302
158 # check that the issues were updated
158 # check that the issues were updated
159 assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id}
159 assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id}
160 end
160 end
161
161
162 def test_bulk_update_on_different_projects
162 def test_bulk_update_on_different_projects
163 @request.session[:user_id] = 2
163 @request.session[:user_id] = 2
164 # update time entry activity
164 # update time entry activity
165 post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 }
165 post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 }
166
166
167 assert_response 302
167 assert_response 302
168 # check that the issues were updated
168 # 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}
169 assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id}
170 end
170 end
171
171
172 def test_bulk_update_on_different_projects_without_rights
172 def test_bulk_update_on_different_projects_without_rights
173 @request.session[:user_id] = 3
173 @request.session[:user_id] = 3
174 user = User.find(3)
174 user = User.find(3)
175 action = { :controller => "timelog", :action => "bulk_update" }
175 action = { :controller => "timelog", :action => "bulk_update" }
176 assert user.allowed_to?(action, TimeEntry.find(1).project)
176 assert user.allowed_to?(action, TimeEntry.find(1).project)
177 assert ! user.allowed_to?(action, TimeEntry.find(5).project)
177 assert ! user.allowed_to?(action, TimeEntry.find(5).project)
178 post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 }
178 post :bulk_update, :ids => [1, 5], :time_entry => { :activity_id => 9 }
179 assert_response 403
179 assert_response 403
180 end
180 end
181
181
182 def test_bulk_update_custom_field
182 def test_bulk_update_custom_field
183 @request.session[:user_id] = 2
183 @request.session[:user_id] = 2
184 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }
184 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} }
185
185
186 assert_response 302
186 assert_response 302
187 assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value}
187 assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value}
188 end
188 end
189
189
190 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
190 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter
191 @request.session[:user_id] = 2
191 @request.session[:user_id] = 2
192 post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
192 post :bulk_update, :ids => [1,2], :back_url => '/time_entries'
193
193
194 assert_response :redirect
194 assert_response :redirect
195 assert_redirected_to '/time_entries'
195 assert_redirected_to '/time_entries'
196 end
196 end
197
197
198 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
198 def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host
199 @request.session[:user_id] = 2
199 @request.session[:user_id] = 2
200 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
200 post :bulk_update, :ids => [1,2], :back_url => 'http://google.com'
201
201
202 assert_response :redirect
202 assert_response :redirect
203 assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier
203 assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier
204 end
204 end
205
205
206 def test_destroy
206 def test_destroy
207 @request.session[:user_id] = 2
207 @request.session[:user_id] = 2
208 delete :destroy, :id => 1
208 delete :destroy, :id => 1
209 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
209 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
210 assert_equal I18n.t(:notice_successful_delete), flash[:notice]
210 assert_equal I18n.t(:notice_successful_delete), flash[:notice]
211 assert_nil TimeEntry.find_by_id(1)
211 assert_nil TimeEntry.find_by_id(1)
212 end
212 end
213
213
214 def test_destroy_should_fail
214 def test_destroy_should_fail
215 # simulate that this fails (e.g. due to a plugin), see #5700
215 # simulate that this fails (e.g. due to a plugin), see #5700
216 TimeEntry.class_eval do
216 TimeEntry.any_instance.expects(:destroy).returns(false)
217 before_destroy :stop_callback_chain
218 def stop_callback_chain ; return false ; end
219 end
220
217
221 @request.session[:user_id] = 2
218 @request.session[:user_id] = 2
222 delete :destroy, :id => 1
219 delete :destroy, :id => 1
223 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
220 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
224 assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
221 assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
225 assert_not_nil TimeEntry.find_by_id(1)
222 assert_not_nil TimeEntry.find_by_id(1)
226
227 # remove the simulation
228 TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain }
229 end
223 end
230
224
231 def test_index_all_projects
225 def test_index_all_projects
232 get :index
226 get :index
233 assert_response :success
227 assert_response :success
234 assert_template 'index'
228 assert_template 'index'
235 assert_not_nil assigns(:total_hours)
229 assert_not_nil assigns(:total_hours)
236 assert_equal "162.90", "%.2f" % assigns(:total_hours)
230 assert_equal "162.90", "%.2f" % assigns(:total_hours)
237 assert_tag :form,
231 assert_tag :form,
238 :attributes => {:action => "/time_entries", :id => 'query_form'}
232 :attributes => {:action => "/time_entries", :id => 'query_form'}
239 end
233 end
240
234
241 def test_index_at_project_level
235 def test_index_at_project_level
242 get :index, :project_id => 'ecookbook'
236 get :index, :project_id => 'ecookbook'
243 assert_response :success
237 assert_response :success
244 assert_template 'index'
238 assert_template 'index'
245 assert_not_nil assigns(:entries)
239 assert_not_nil assigns(:entries)
246 assert_equal 4, assigns(:entries).size
240 assert_equal 4, assigns(:entries).size
247 # project and subproject
241 # project and subproject
248 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
242 assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort
249 assert_not_nil assigns(:total_hours)
243 assert_not_nil assigns(:total_hours)
250 assert_equal "162.90", "%.2f" % assigns(:total_hours)
244 assert_equal "162.90", "%.2f" % assigns(:total_hours)
251 # display all time by default
245 # display all time by default
252 assert_equal '2007-03-12'.to_date, assigns(:from)
246 assert_equal '2007-03-12'.to_date, assigns(:from)
253 assert_equal '2007-04-22'.to_date, assigns(:to)
247 assert_equal '2007-04-22'.to_date, assigns(:to)
254 assert_tag :form,
248 assert_tag :form,
255 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
249 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
256 end
250 end
257
251
258 def test_index_at_project_level_with_date_range
252 def test_index_at_project_level_with_date_range
259 get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30'
253 get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30'
260 assert_response :success
254 assert_response :success
261 assert_template 'index'
255 assert_template 'index'
262 assert_not_nil assigns(:entries)
256 assert_not_nil assigns(:entries)
263 assert_equal 3, assigns(:entries).size
257 assert_equal 3, assigns(:entries).size
264 assert_not_nil assigns(:total_hours)
258 assert_not_nil assigns(:total_hours)
265 assert_equal "12.90", "%.2f" % assigns(:total_hours)
259 assert_equal "12.90", "%.2f" % assigns(:total_hours)
266 assert_equal '2007-03-20'.to_date, assigns(:from)
260 assert_equal '2007-03-20'.to_date, assigns(:from)
267 assert_equal '2007-04-30'.to_date, assigns(:to)
261 assert_equal '2007-04-30'.to_date, assigns(:to)
268 assert_tag :form,
262 assert_tag :form,
269 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
263 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
270 end
264 end
271
265
272 def test_index_at_project_level_with_period
266 def test_index_at_project_level_with_period
273 get :index, :project_id => 'ecookbook', :period => '7_days'
267 get :index, :project_id => 'ecookbook', :period => '7_days'
274 assert_response :success
268 assert_response :success
275 assert_template 'index'
269 assert_template 'index'
276 assert_not_nil assigns(:entries)
270 assert_not_nil assigns(:entries)
277 assert_not_nil assigns(:total_hours)
271 assert_not_nil assigns(:total_hours)
278 assert_equal Date.today - 7, assigns(:from)
272 assert_equal Date.today - 7, assigns(:from)
279 assert_equal Date.today, assigns(:to)
273 assert_equal Date.today, assigns(:to)
280 assert_tag :form,
274 assert_tag :form,
281 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
275 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
282 end
276 end
283
277
284 def test_index_one_day
278 def test_index_one_day
285 get :index, :project_id => 'ecookbook', :from => "2007-03-23", :to => "2007-03-23"
279 get :index, :project_id => 'ecookbook', :from => "2007-03-23", :to => "2007-03-23"
286 assert_response :success
280 assert_response :success
287 assert_template 'index'
281 assert_template 'index'
288 assert_not_nil assigns(:total_hours)
282 assert_not_nil assigns(:total_hours)
289 assert_equal "4.25", "%.2f" % assigns(:total_hours)
283 assert_equal "4.25", "%.2f" % assigns(:total_hours)
290 assert_tag :form,
284 assert_tag :form,
291 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
285 :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'}
292 end
286 end
293
287
294 def test_index_at_issue_level
288 def test_index_at_issue_level
295 get :index, :issue_id => 1
289 get :index, :issue_id => 1
296 assert_response :success
290 assert_response :success
297 assert_template 'index'
291 assert_template 'index'
298 assert_not_nil assigns(:entries)
292 assert_not_nil assigns(:entries)
299 assert_equal 2, assigns(:entries).size
293 assert_equal 2, assigns(:entries).size
300 assert_not_nil assigns(:total_hours)
294 assert_not_nil assigns(:total_hours)
301 assert_equal 154.25, assigns(:total_hours)
295 assert_equal 154.25, assigns(:total_hours)
302 # display all time based on what's been logged
296 # display all time based on what's been logged
303 assert_equal '2007-03-12'.to_date, assigns(:from)
297 assert_equal '2007-03-12'.to_date, assigns(:from)
304 assert_equal '2007-04-22'.to_date, assigns(:to)
298 assert_equal '2007-04-22'.to_date, assigns(:to)
305 # TODO: remove /projects/:project_id/issues/:issue_id/time_entries routes
299 # TODO: remove /projects/:project_id/issues/:issue_id/time_entries routes
306 # to use /issues/:issue_id/time_entries
300 # to use /issues/:issue_id/time_entries
307 assert_tag :form,
301 assert_tag :form,
308 :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'}
302 :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'}
309 end
303 end
310
304
311 def test_index_atom_feed
305 def test_index_atom_feed
312 get :index, :project_id => 1, :format => 'atom'
306 get :index, :project_id => 1, :format => 'atom'
313 assert_response :success
307 assert_response :success
314 assert_equal 'application/atom+xml', @response.content_type
308 assert_equal 'application/atom+xml', @response.content_type
315 assert_not_nil assigns(:items)
309 assert_not_nil assigns(:items)
316 assert assigns(:items).first.is_a?(TimeEntry)
310 assert assigns(:items).first.is_a?(TimeEntry)
317 end
311 end
318
312
319 def test_index_all_projects_csv_export
313 def test_index_all_projects_csv_export
320 Setting.date_format = '%m/%d/%Y'
314 Setting.date_format = '%m/%d/%Y'
321 get :index, :format => 'csv'
315 get :index, :format => 'csv'
322 assert_response :success
316 assert_response :success
323 assert_equal 'text/csv', @response.content_type
317 assert_equal 'text/csv', @response.content_type
324 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
318 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
325 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
319 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
326 end
320 end
327
321
328 def test_index_csv_export
322 def test_index_csv_export
329 Setting.date_format = '%m/%d/%Y'
323 Setting.date_format = '%m/%d/%Y'
330 get :index, :project_id => 1, :format => 'csv'
324 get :index, :project_id => 1, :format => 'csv'
331 assert_response :success
325 assert_response :success
332 assert_equal 'text/csv', @response.content_type
326 assert_equal 'text/csv', @response.content_type
333 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
327 assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n")
334 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
328 assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n")
335 end
329 end
336 end
330 end
General Comments 0
You need to be logged in to leave comments. Login now