attachement.copy(:container => self)
end
end
+
unless options[:watchers] == false
- self.watcher_user_ids =
- issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}.map(&:id)
+ self.watcher_user_ids = issue.visible_watcher_users.select{|u| u.status == User::STATUS_ACTIVE}.map(&:id)
end
@copied_from = issue
@copy_options = options
user2 = User.find(3)
issue = Issue.find(8)
+ User.current = user
+
Watcher.create!(:user => user, :watchable => issue)
Watcher.create!(:user => user2, :watchable => issue)
assert !issue.watched_by?(user2)
end
+ def test_copy_should_not_copy_watchers_without_permission
+ user = User.find(2)
+ user2 = User.find(3)
+ issue = Issue.find(8)
+
+ Role.find(1).remove_permission! :view_issue_watchers
+ User.current = user
+
+ Watcher.create!(:user => user, :watchable => issue)
+ Watcher.create!(:user => user2, :watchable => issue)
+
+ issue = Issue.new.copy_from(8)
+
+ assert issue.save
+ assert issue.watched_by?(user)
+ assert !issue.watched_by?(user2)
+ end
+
def test_copy_should_clear_subtasks_target_version_if_locked_or_closed
version = Version.new(:project => Project.find(1), :name => '2.1')
version.save!