Mercurial > hg > soundsoftware-site
comparison test/functional/timelog_controller_test.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
222 :spent_on => '2008-03-14', | 222 :spent_on => '2008-03-14', |
223 :hours => '7.3'} | 223 :hours => '7.3'} |
224 end | 224 end |
225 | 225 |
226 assert_redirected_to '/projects/ecookbook/time_entries' | 226 assert_redirected_to '/projects/ecookbook/time_entries' |
227 time_entry = TimeEntry.first(:order => 'id DESC') | 227 time_entry = TimeEntry.order('id DESC').first |
228 assert_equal 1, time_entry.project_id | 228 assert_equal 1, time_entry.project_id |
229 end | 229 end |
230 | 230 |
231 def test_create_without_project_should_fail_with_issue_not_inside_project | 231 def test_create_without_project_should_fail_with_issue_not_inside_project |
232 @request.session[:user_id] = 2 | 232 @request.session[:user_id] = 2 |
285 entry.reload | 285 entry.reload |
286 | 286 |
287 assert_equal 8, entry.hours | 287 assert_equal 8, entry.hours |
288 assert_equal 2, entry.issue_id | 288 assert_equal 2, entry.issue_id |
289 assert_equal 2, entry.user_id | 289 assert_equal 2, entry.user_id |
290 end | |
291 | |
292 def test_update_should_allow_to_change_issue_to_another_project | |
293 entry = TimeEntry.generate!(:issue_id => 1) | |
294 | |
295 @request.session[:user_id] = 1 | |
296 put :update, :id => entry.id, :time_entry => {:issue_id => '5'} | |
297 assert_response 302 | |
298 entry.reload | |
299 | |
300 assert_equal 5, entry.issue_id | |
301 assert_equal 3, entry.project_id | |
302 end | |
303 | |
304 def test_update_should_not_allow_to_change_issue_to_an_invalid_project | |
305 entry = TimeEntry.generate!(:issue_id => 1) | |
306 Project.find(3).disable_module!(:time_tracking) | |
307 | |
308 @request.session[:user_id] = 1 | |
309 put :update, :id => entry.id, :time_entry => {:issue_id => '5'} | |
310 assert_response 200 | |
311 assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages | |
290 end | 312 end |
291 | 313 |
292 def test_get_bulk_edit | 314 def test_get_bulk_edit |
293 @request.session[:user_id] = 2 | 315 @request.session[:user_id] = 2 |
294 get :bulk_edit, :ids => [1, 2] | 316 get :bulk_edit, :ids => [1, 2] |
324 # update time entry activity | 346 # update time entry activity |
325 post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} | 347 post :bulk_update, :ids => [1, 2], :time_entry => { :activity_id => 9} |
326 | 348 |
327 assert_response 302 | 349 assert_response 302 |
328 # check that the issues were updated | 350 # check that the issues were updated |
329 assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id} | 351 assert_equal [9, 9], TimeEntry.where(:id => [1, 2]).collect {|i| i.activity_id} |
330 end | 352 end |
331 | 353 |
332 def test_bulk_update_with_failure | 354 def test_bulk_update_with_failure |
333 @request.session[:user_id] = 2 | 355 @request.session[:user_id] = 2 |
334 post :bulk_update, :ids => [1, 2], :time_entry => { :hours => 'A'} | 356 post :bulk_update, :ids => [1, 2], :time_entry => { :hours => 'A'} |
345 # update time entry activity | 367 # update time entry activity |
346 post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } | 368 post :bulk_update, :ids => [1, 2, 4], :time_entry => { :activity_id => 9 } |
347 | 369 |
348 assert_response 302 | 370 assert_response 302 |
349 # check that the issues were updated | 371 # check that the issues were updated |
350 assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id} | 372 assert_equal [9, 9, 9], TimeEntry.where(:id => [1, 2, 4]).collect {|i| i.activity_id} |
351 end | 373 end |
352 | 374 |
353 def test_bulk_update_on_different_projects_without_rights | 375 def test_bulk_update_on_different_projects_without_rights |
354 @request.session[:user_id] = 3 | 376 @request.session[:user_id] = 3 |
355 user = User.find(3) | 377 user = User.find(3) |
363 def test_bulk_update_custom_field | 385 def test_bulk_update_custom_field |
364 @request.session[:user_id] = 2 | 386 @request.session[:user_id] = 2 |
365 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } | 387 post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } |
366 | 388 |
367 assert_response 302 | 389 assert_response 302 |
368 assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value} | 390 assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value} |
369 end | 391 end |
370 | 392 |
371 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter | 393 def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter |
372 @request.session[:user_id] = 2 | 394 @request.session[:user_id] = 2 |
373 post :bulk_update, :ids => [1,2], :back_url => '/time_entries' | 395 post :bulk_update, :ids => [1,2], :back_url => '/time_entries' |