Mercurial > hg > soundsoftware-site
diff 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 |
line wrap: on
line diff
--- a/test/functional/timelog_controller_test.rb Tue Sep 09 09:28:31 2014 +0100 +++ b/test/functional/timelog_controller_test.rb Tue Sep 09 09:29:00 2014 +0100 @@ -224,7 +224,7 @@ end assert_redirected_to '/projects/ecookbook/time_entries' - time_entry = TimeEntry.first(:order => 'id DESC') + time_entry = TimeEntry.order('id DESC').first assert_equal 1, time_entry.project_id end @@ -289,6 +289,28 @@ assert_equal 2, entry.user_id end + def test_update_should_allow_to_change_issue_to_another_project + entry = TimeEntry.generate!(:issue_id => 1) + + @request.session[:user_id] = 1 + put :update, :id => entry.id, :time_entry => {:issue_id => '5'} + assert_response 302 + entry.reload + + assert_equal 5, entry.issue_id + assert_equal 3, entry.project_id + end + + def test_update_should_not_allow_to_change_issue_to_an_invalid_project + entry = TimeEntry.generate!(:issue_id => 1) + Project.find(3).disable_module!(:time_tracking) + + @request.session[:user_id] = 1 + put :update, :id => entry.id, :time_entry => {:issue_id => '5'} + assert_response 200 + assert_include "Issue is invalid", assigns(:time_entry).errors.full_messages + end + def test_get_bulk_edit @request.session[:user_id] = 2 get :bulk_edit, :ids => [1, 2] @@ -326,7 +348,7 @@ assert_response 302 # check that the issues were updated - assert_equal [9, 9], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.activity_id} + assert_equal [9, 9], TimeEntry.where(:id => [1, 2]).collect {|i| i.activity_id} end def test_bulk_update_with_failure @@ -347,7 +369,7 @@ assert_response 302 # check that the issues were updated - assert_equal [9, 9, 9], TimeEntry.find_all_by_id([1, 2, 4]).collect {|i| i.activity_id} + assert_equal [9, 9, 9], TimeEntry.where(:id => [1, 2, 4]).collect {|i| i.activity_id} end def test_bulk_update_on_different_projects_without_rights @@ -365,7 +387,7 @@ post :bulk_update, :ids => [1, 2], :time_entry => { :custom_field_values => {'10' => '0'} } assert_response 302 - assert_equal ["0", "0"], TimeEntry.find_all_by_id([1, 2]).collect {|i| i.custom_value_for(10).value} + assert_equal ["0", "0"], TimeEntry.where(:id => [1, 2]).collect {|i| i.custom_value_for(10).value} end def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter