]> source.dussan.org Git - redmine.git/commitdiff
Merged r21081 to 4.1-stable (#34856).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 27 Jul 2021 20:45:30 +0000 (20:45 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 27 Jul 2021 20:45:30 +0000 (20:45 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@21094 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb
test/functional/issues_controller_test.rb

index 88d9c4cd99fd6efbd53137ede1423b358097fd79..c12a05186c030d2dd9acbdc1cd549ed2589c9008 100644 (file)
@@ -113,6 +113,13 @@ class TimeEntry < ActiveRecord::Base
             self.project_id = issue.project_id
           end
           @invalid_issue_id = nil
+        elsif user.allowed_to?(:log_time, issue.project) && issue.assigned_to_id_changed? && issue.previous_assignee == User.current
+          current_assignee = issue.assigned_to
+          issue.assigned_to = issue.previous_assignee
+          unless issue.visible?(user)
+            @invalid_issue_id = issue_id
+          end
+          issue.assigned_to = current_assignee
         else
           @invalid_issue_id = issue_id
         end
index 2ee1a2c4136497a81285b31d01f3d524eed9485f..48ecddafd5d76e0ce9e509292b11f3a8b8634cd1 100644 (file)
@@ -5640,6 +5640,29 @@ class IssuesControllerTest < Redmine::ControllerTest
     assert_select 'input[name=?][value=?]', 'time_entry[comments]', 'this is my comment'
   end
 
+  def test_put_with_spent_time_when_assigned_to_of_private_issue_is_update_at_the_same_time
+    @request.session[:user_id] = 3
+    Role.find(2).update! :issues_visibility => 'own'
+    private_issue = Issue.find(3)
+
+    assert_difference('TimeEntry.count', 1) do
+      put(
+        :update,
+        params: {
+          id: private_issue.id,
+          issue: { assigned_to_id: nil },
+          time_entry: {
+            comments: "add spent time", activity_id: TimeEntryActivity.first.id, hours: 1
+          }
+        }
+      )
+    end
+    assert_select '#errorExplanation', {text: /Log time is invalid/, count: 0}
+    assert_select '#errorExplanation', {text: /Issue is invalid/, count: 0}
+    assert_redirected_to action: 'show', id: private_issue.id
+    assert_not private_issue.reload.visible?
+  end
+
   def test_put_update_should_allow_fixed_version_to_be_set_to_a_subproject
     issue = Issue.find(2)
     @request.session[:user_id] = 2