@@ -1,17 +1,17 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 |
# |
|
|
3 |
# Copyright (C) 2006-20 |
|
|
2 | # Redmine - project management software | |
|
3 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
|
4 | 4 | # |
|
5 | 5 | # This program is free software; you can redistribute it and/or |
|
6 | 6 | # modify it under the terms of the GNU General Public License |
|
7 | 7 | # as published by the Free Software Foundation; either version 2 |
|
8 | 8 | # of the License, or (at your option) any later version. |
|
9 |
# |
|
|
9 | # | |
|
10 | 10 | # This program is distributed in the hope that it will be useful, |
|
11 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | 13 | # GNU General Public License for more details. |
|
14 |
# |
|
|
14 | # | |
|
15 | 15 | # You should have received a copy of the GNU General Public License |
|
16 | 16 | # along with this program; if not, write to the Free Software |
|
17 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
@@ -30,7 +30,7 class TimelogControllerTest < ActionController::TestCase | |||
|
30 | 30 | @request = ActionController::TestRequest.new |
|
31 | 31 | @response = ActionController::TestResponse.new |
|
32 | 32 | end |
|
33 | ||
|
33 | ||
|
34 | 34 | def test_get_new |
|
35 | 35 | @request.session[:user_id] = 3 |
|
36 | 36 | get :new, :project_id => 1 |
@@ -40,14 +40,13 class TimelogControllerTest < ActionController::TestCase | |||
|
40 | 40 | assert_tag :tag => 'option', :attributes => { :selected => 'selected' }, |
|
41 | 41 | :content => 'Development' |
|
42 | 42 | end |
|
43 | ||
|
43 | ||
|
44 | 44 | def test_get_new_should_only_show_active_time_entry_activities |
|
45 | 45 | @request.session[:user_id] = 3 |
|
46 | 46 | get :new, :project_id => 1 |
|
47 | 47 | assert_response :success |
|
48 | 48 | assert_template 'edit' |
|
49 | 49 | assert_no_tag :tag => 'option', :content => 'Inactive Activity' |
|
50 | ||
|
51 | 50 | end |
|
52 | 51 | |
|
53 | 52 | def test_get_edit_existing_time |
@@ -58,7 +57,7 class TimelogControllerTest < ActionController::TestCase | |||
|
58 | 57 | # Default activity selected |
|
59 | 58 | assert_tag :tag => 'form', :attributes => { :action => '/projects/ecookbook/time_entries/2' } |
|
60 | 59 | end |
|
61 | ||
|
60 | ||
|
62 | 61 | def test_get_edit_with_an_existing_time_entry_with_inactive_activity |
|
63 | 62 | te = TimeEntry.find(1) |
|
64 | 63 | te.activity = TimeEntryActivity.find_by_name("Inactive Activity") |
@@ -71,7 +70,7 class TimelogControllerTest < ActionController::TestCase | |||
|
71 | 70 | # Blank option since nothing is pre-selected |
|
72 | 71 | assert_tag :tag => 'option', :content => '--- Please select ---' |
|
73 | 72 | end |
|
74 | ||
|
73 | ||
|
75 | 74 | def test_post_create |
|
76 | 75 | # TODO: should POST to issuesβ time log instead of project. change form |
|
77 | 76 | # and routing |
@@ -84,7 +83,7 class TimelogControllerTest < ActionController::TestCase | |||
|
84 | 83 | :issue_id => '1', |
|
85 | 84 | :hours => '7.3'} |
|
86 | 85 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
87 | ||
|
86 | ||
|
88 | 87 | i = Issue.find(1) |
|
89 | 88 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') |
|
90 | 89 | assert_not_nil t |
@@ -107,26 +106,26 class TimelogControllerTest < ActionController::TestCase | |||
|
107 | 106 | :spent_on => '2008-03-14', |
|
108 | 107 | :hours => '7.3'} |
|
109 | 108 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
110 | ||
|
109 | ||
|
111 | 110 | t = TimeEntry.find_by_comments('Some work on TimelogControllerTest') |
|
112 | 111 | assert_not_nil t |
|
113 | 112 | assert_equal 11, t.activity_id |
|
114 | 113 | assert_equal 7.3, t.hours |
|
115 | 114 | assert_equal 3, t.user_id |
|
116 | 115 | end |
|
117 | ||
|
116 | ||
|
118 | 117 | def test_update |
|
119 | 118 | entry = TimeEntry.find(1) |
|
120 | 119 | assert_equal 1, entry.issue_id |
|
121 | 120 | assert_equal 2, entry.user_id |
|
122 | ||
|
121 | ||
|
123 | 122 | @request.session[:user_id] = 1 |
|
124 | 123 | put :update, :id => 1, |
|
125 | 124 | :time_entry => {:issue_id => '2', |
|
126 | 125 | :hours => '8'} |
|
127 | 126 | assert_redirected_to :action => 'index', :project_id => 'ecookbook' |
|
128 | 127 | entry.reload |
|
129 | ||
|
128 | ||
|
130 | 129 | assert_equal 8, entry.hours |
|
131 | 130 | assert_equal 2, entry.issue_id |
|
132 | 131 | assert_equal 2, entry.user_id |
@@ -137,7 +136,7 class TimelogControllerTest < ActionController::TestCase | |||
|
137 | 136 | get :bulk_edit, :ids => [1, 2] |
|
138 | 137 | assert_response :success |
|
139 | 138 | assert_template 'bulk_edit' |
|
140 | ||
|
139 | ||
|
141 | 140 | # System wide custom field |
|
142 | 141 | assert_tag :select, :attributes => {:name => 'time_entry[custom_field_values][10]'} |
|
143 | 142 | end |
@@ -153,7 +152,7 class TimelogControllerTest < ActionController::TestCase | |||
|
153 | 152 | @request.session[:user_id] = 2 |
|
154 | 153 | # update time entry activity |
|
155 | 154 | post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} |
|
156 | ||
|
155 | ||
|
157 | 156 | assert_response 302 |
|
158 | 157 | # check that the issues were updated |
|
159 | 158 | assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id} |
@@ -163,7 +162,7 class TimelogControllerTest < ActionController::TestCase | |||
|
163 | 162 | @request.session[:user_id] = 2 |
|
164 | 163 | # update time entry activity |
|
165 | 164 | post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } |
|
166 | ||
|
165 | ||
|
167 | 166 | assert_response 302 |
|
168 | 167 | # check that the issues were updated |
|
169 | 168 | assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id} |
@@ -182,7 +181,7 class TimelogControllerTest < ActionController::TestCase | |||
|
182 | 181 | def test_bulk_update_custom_field |
|
183 | 182 | @request.session[:user_id] = 2 |
|
184 | 183 | post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } |
|
185 | ||
|
184 | ||
|
186 | 185 | assert_response 302 |
|
187 | 186 | assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value} |
|
188 | 187 | end |
@@ -202,7 +201,7 class TimelogControllerTest < ActionController::TestCase | |||
|
202 | 201 | assert_response :redirect |
|
203 | 202 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => Project.find(1).identifier |
|
204 | 203 | end |
|
205 | ||
|
204 | ||
|
206 | 205 | def test_destroy |
|
207 | 206 | @request.session[:user_id] = 2 |
|
208 | 207 | delete :destroy, :id => 1 |
@@ -210,7 +209,7 class TimelogControllerTest < ActionController::TestCase | |||
|
210 | 209 | assert_equal I18n.t(:notice_successful_delete), flash[:notice] |
|
211 | 210 | assert_nil TimeEntry.find_by_id(1) |
|
212 | 211 | end |
|
213 | ||
|
212 | ||
|
214 | 213 | def test_destroy_should_fail |
|
215 | 214 | # simulate that this fails (e.g. due to a plugin), see #5700 |
|
216 | 215 | TimeEntry.any_instance.expects(:destroy).returns(false) |
@@ -221,7 +220,7 class TimelogControllerTest < ActionController::TestCase | |||
|
221 | 220 | assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error] |
|
222 | 221 | assert_not_nil TimeEntry.find_by_id(1) |
|
223 | 222 | end |
|
224 | ||
|
223 | ||
|
225 | 224 | def test_index_all_projects |
|
226 | 225 | get :index |
|
227 | 226 | assert_response :success |
@@ -231,7 +230,7 class TimelogControllerTest < ActionController::TestCase | |||
|
231 | 230 | assert_tag :form, |
|
232 | 231 | :attributes => {:action => "/time_entries", :id => 'query_form'} |
|
233 | 232 | end |
|
234 | ||
|
233 | ||
|
235 | 234 | def test_index_at_project_level |
|
236 | 235 | get :index, :project_id => 'ecookbook' |
|
237 | 236 | assert_response :success |
@@ -248,7 +247,7 class TimelogControllerTest < ActionController::TestCase | |||
|
248 | 247 | assert_tag :form, |
|
249 | 248 | :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} |
|
250 | 249 | end |
|
251 | ||
|
250 | ||
|
252 | 251 | def test_index_at_project_level_with_date_range |
|
253 | 252 | get :index, :project_id => 'ecookbook', :from => '2007-03-20', :to => '2007-04-30' |
|
254 | 253 | assert_response :success |
@@ -284,7 +283,7 class TimelogControllerTest < ActionController::TestCase | |||
|
284 | 283 | assert_tag :form, |
|
285 | 284 | :attributes => {:action => "/projects/ecookbook/time_entries", :id => 'query_form'} |
|
286 | 285 | end |
|
287 | ||
|
286 | ||
|
288 | 287 | def test_index_at_issue_level |
|
289 | 288 | get :index, :issue_id => 1 |
|
290 | 289 | assert_response :success |
@@ -301,7 +300,7 class TimelogControllerTest < ActionController::TestCase | |||
|
301 | 300 | assert_tag :form, |
|
302 | 301 | :attributes => {:action => "/projects/ecookbook/issues/1/time_entries", :id => 'query_form'} |
|
303 | 302 | end |
|
304 | ||
|
303 | ||
|
305 | 304 | def test_index_atom_feed |
|
306 | 305 | get :index, :project_id => 1, :format => 'atom' |
|
307 | 306 | assert_response :success |
@@ -309,7 +308,7 class TimelogControllerTest < ActionController::TestCase | |||
|
309 | 308 | assert_not_nil assigns(:items) |
|
310 | 309 | assert assigns(:items).first.is_a?(TimeEntry) |
|
311 | 310 | end |
|
312 | ||
|
311 | ||
|
313 | 312 | def test_index_all_projects_csv_export |
|
314 | 313 | Setting.date_format = '%m/%d/%Y' |
|
315 | 314 | get :index, :format => 'csv' |
@@ -318,7 +317,7 class TimelogControllerTest < ActionController::TestCase | |||
|
318 | 317 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment,Overtime\n") |
|
319 | 318 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\",\"\"\n") |
|
320 | 319 | end |
|
321 | ||
|
320 | ||
|
322 | 321 | def test_index_csv_export |
|
323 | 322 | Setting.date_format = '%m/%d/%Y' |
|
324 | 323 | get :index, :project_id => 1, :format => 'csv' |
General Comments 0
You need to be logged in to leave comments.
Login now