##// END OF EJS Templates
Let user choose an issue of another project when updating a time entry (#16338)....
Jean-Philippe Lang -
r12715:dd70327ce4d1
parent child
Show More
@@ -77,6 +77,16 class TimeEntry < ActiveRecord::Base
77 end
77 end
78 end
78 end
79
79
80 def safe_attributes=(attrs, user=User.current)
81 attrs = super
82 if !new_record? && issue && issue.project_id != project_id
83 if user.allowed_to?(:log_time, issue.project)
84 self.project_id = issue.project_id
85 end
86 end
87 attrs
88 end
89
80 def set_project_if_nil
90 def set_project_if_nil
81 self.project = issue.project if issue && project.nil?
91 self.project = issue.project if issue && project.nil?
82 end
92 end
@@ -289,6 +289,28 class TimelogControllerTest < ActionController::TestCase
289 assert_equal 2, entry.user_id
289 assert_equal 2, entry.user_id
290 end
290 end
291
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
312 end
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]
General Comments 0
You need to be logged in to leave comments. Login now