Defect #28765
closedCopying an issue fails if the issue is watched by a locked user
0%
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
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.
Updated by Go MAEDA over 6 years ago
- Related to Defect #27863: If version is closed or locked subtasks don't get copied added
Updated by Marius BĂLTEANU over 6 years ago
- File 0001-do-not-propose-locked-watchers-when-copying-an-issue.patch 0001-do-not-propose-locked-watchers-when-copying-an-issue.patch added
- Target version set to Candidate for next minor release
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.
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
Updated by Marius BĂLTEANU over 6 years ago
- File 0001-unit-test-for-locked-watchers.patch 0001-unit-test-for-locked-watchers.patch added
- Assignee changed from Marius BĂLTEANU to Go MAEDA
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).
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:
Updated by Andreas Deininger over 6 years ago
- File 0001-unit-test-for-locked-watchers_corrected.patch 0001-unit-test-for-locked-watchers_corrected.patch added
In the unit test patch, the name of the test method is misspelled. This typo is fixed in the attached patch.
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".
Updated by Go MAEDA about 6 years ago
- Status changed from Confirmed to Resolved
- Assignee set to Go MAEDA
- Resolution set to Fixed
Updated by Go MAEDA about 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.