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