GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit e01bf678 authored by maeda's avatar maeda

Fix: Copying an issue fails if the issue is watched by a locked user (#28765).

Patch by Marius BALTEANU.


git-svn-id: https://svn.redmine.org/redmine/trunk@17342 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 408731f7
......@@ -312,7 +312,7 @@ module IssuesHelper
# Returns an array of users that are proposed as watchers
# on the new issue form
def users_for_new_issue_watchers(issue)
users = issue.watcher_users
users = issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}
if issue.project.users.count <= 20
users = (users + issue.project.users.sort).uniq
end
......
......@@ -274,7 +274,8 @@ class Issue < ActiveRecord::Base
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
......
......@@ -3916,6 +3916,29 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select 'input[type=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
end
def test_new_as_copy_should_not_propose_locked_watchers
@request.session[:user_id] = 2
issue = Issue.find(1)
user = User.generate!
user2 = User.generate!
Watcher.create!(:watchable => issue, :user => user)
Watcher.create!(:watchable => issue, :user => user2)
user2.status = User::STATUS_LOCKED
user2.save!
get :new, :params => {
:project_id => 1,
:copy_from => 1
}
assert_select 'input[type=checkbox][name=?][checked=checked]', 'issue[watcher_user_ids][]', 1
assert_select 'input[type=checkbox][name=?][checked=checked][value=?]', 'issue[watcher_user_ids][]', user.id.to_s
assert_select 'input[type=checkbox][name=?][checked=checked][value=?]', 'issue[watcher_user_ids][]', user2.id.to_s, 0
assert_select 'input[type=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
end
def test_new_as_copy_with_invalid_issue_should_respond_with_404
@request.session[:user_id] = 2
get :new, :params => {
......
......@@ -1375,6 +1375,24 @@ class IssueTest < ActiveSupport::TestCase
assert_not_nil copied_closed.closed_on
end
def test_copy_should_not_copy_locked_watchers
user = User.find(2)
user2 = User.find(3)
issue = Issue.find(8)
Watcher.create!(:user => user, :watchable => issue)
Watcher.create!(:user => user2, :watchable => issue)
user2.status = User::STATUS_LOCKED
user2.save!
issue = Issue.new.copy_from(8)
assert issue.save
assert issue.watched_by?(user)
assert !issue.watched_by?(user2)
end
def test_should_not_call_after_project_change_on_creation
issue = Issue.new(:project_id => 1, :tracker_id => 1, :status_id => 1,
:subject => 'Test', :author_id => 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment