Project

General

Profile

Actions

Defect #28765

closed

Copying an issue fails if the issue is watched by a locked user

Added by Ayami Yasuoka over 6 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When copying the parent issue having child issue, some issues could not be copied.
The "Copy subtasks" checkbox is checked.

After checking the log, it turned out that only the issue for which the member of the lock account is set to the watcher has not been copied.
Even if the members of the lock account are set on the watcher, I want you to be able to copy the issue.

Redmine 3.4.2
rudy version:2.3.3-p222
Rails 4.2.8

I will post it for the first time. I'm sorry if I made a mistake in my way.


Files


Related issues

Related to Redmine - Defect #27863: If version is closed or locked subtasks don't get copied ClosedGo MAEDA

Actions
Actions #1

Updated by Go MAEDA over 6 years ago

  • Tracker changed from Feature to Defect
  • Subject changed from Issue copy can not be done if lock account member is set on watcher to Copying an issue fails if the issue is watched by a locked user
  • Category set to Issues

I confirmed the problem. Copying an issue fails if the issue is watched by a locked user and a validation error "Watchers is invalid" is displayed.

I will post it for the first time. I'm sorry if I made a mistake in my way.

There was no problem at all. Thank you for reporting this issue.

Actions #2

Updated by Go MAEDA over 6 years ago

  • Status changed from New to Confirmed
Actions #3

Updated by Go MAEDA over 6 years ago

  • Related to Defect #27863: If version is closed or locked subtasks don't get copied added
Actions #4

Updated by Marius BĂLTEANU over 6 years ago

Attached is a patch with a test included that fixes this issue. I chose to propose in the UI only active users as watchers when copying an issue.

Actions #5

Updated by Go MAEDA over 6 years ago

  • Assignee set to Marius BĂLTEANU

Thank you for working on this issue, Marius. I confirmed that the patch fixes the problem.

But I noticed that inactive users should be excluded not only in the UI but also in Issue#copy_from method because there still be a problem even after applying the patch. Issues which have locked watchers are not copied when admins use project copy feature.

What do you think including the following code in your patch?

Index: app/models/issue.rb
===================================================================
--- app/models/issue.rb    (revision 17329)
+++ app/models/issue.rb    (working copy)
@@ -274,7 +274,8 @@
       end
     end
     unless options[:watchers] == false
-      self.watcher_user_ids = issue.watcher_user_ids.dup
+      self.watcher_user_ids =
+        issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}.map(&:id)
     end
     @copied_from = issue
     @copy_options = options
Actions #6

Updated by Marius BĂLTEANU over 6 years ago

Oh, I didn't think to this case, thanks for finding it.

It looks good and I made a unit test also for this scenario (attached).

Actions #7

Updated by Go MAEDA over 6 years ago

  • Assignee deleted (Go MAEDA)
  • Target version changed from Candidate for next minor release to 3.4.6

Marius BALTEANU wrote:

It looks good and I made a unit test also for this scenario (attached).

Great, the patch looks perfect now. I am setting target version to 3.4.6. The patches to be committed are as follows:

Actions #8

Updated by Andreas Deininger over 6 years ago

In the unit test patch, the name of the test method is misspelled. This typo is fixed in the attached patch.

Actions #9

Updated by Go MAEDA over 6 years ago

Andreas Deininger wrote:

In the unit test patch, the name of the test method is misspelled. This typo is fixed in the attached patch.

Thank you for pointing out that "shoud" should be "should".

Actions #10

Updated by Go MAEDA over 6 years ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed
Actions #11

Updated by Go MAEDA over 6 years ago

  • Status changed from Resolved to Closed

Committed to the trunk and 3.4-stable branch. Thank you all for reporting and fixing this issue.

Actions

Also available in: Atom PDF