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.
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
- 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.
- Status changed from New to Confirmed
- Related to Defect #27863: If version is closed or locked subtasks don't get copied added
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.
- 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
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).
- 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:
In the unit test patch, the name of the test method is misspelled. This typo is fixed in the attached patch.
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".
- Status changed from Confirmed to Resolved
- Assignee set to Go MAEDA
- Resolution set to Fixed
- Status changed from Resolved to Closed
Committed to the trunk and 3.4-stable branch. Thank you all for reporting and fixing this issue.
Also available in: Atom
PDF