summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2018-01-07 22:21:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2018-01-07 22:21:32 +0000
commit721f3927bb13dd6f8369a2f7b44d76f7f748a4df (patch)
treecc58a6c2441e076faabbfe6bf71c5650594fa009
parentc3da53217ce0d6c575223a5505b93a7e85d05e29 (diff)
downloadredmine-721f3927bb13dd6f8369a2f7b44d76f7f748a4df.tar.gz
redmine-721f3927bb13dd6f8369a2f7b44d76f7f748a4df.zip
Merged r17153 to 3.4-stable (#26880).
git-svn-id: http://svn.redmine.org/redmine/branches/3.4-stable@17154 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/views/issues/_watchers_form.html.erb1
-rw-r--r--test/functional/issues_controller_test.rb41
2 files changed, 42 insertions, 0 deletions
diff --git a/app/views/issues/_watchers_form.html.erb b/app/views/issues/_watchers_form.html.erb
index 6d349f4a3..b55e60284 100644
--- a/app/views/issues/_watchers_form.html.erb
+++ b/app/views/issues/_watchers_form.html.erb
@@ -1,4 +1,5 @@
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
+ <%= hidden_field_tag 'issue[watcher_user_ids][]', '' %>
<p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
<span id="watchers_inputs">
<%= watchers_checkboxes(@issue, users_for_new_issue_watchers(@issue)) %>
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 38067b491..40055cb20 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -3860,6 +3860,7 @@ class IssuesControllerTest < Redmine::ControllerTest
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=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
end
def test_new_as_copy_with_invalid_issue_should_respond_with_404
@@ -4196,6 +4197,46 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_equal 1, issue.project_id
end
+ def test_create_as_copy_with_watcher_user_ids_should_copy_watchers
+ @request.session[:user_id] = 2
+ copied = Issue.generate!
+ copied.add_watcher User.find(2)
+ copied.add_watcher User.find(3)
+
+ assert_difference 'Issue.count' do
+ post :create, :params => {
+ :project_id => 1,
+ :copy_from => copied.id,
+ :issue => {
+ :subject => 'Copy cleared watchers',
+ :watcher_user_ids => ['', '3']
+ }
+ }
+ end
+ issue = Issue.order('id DESC').first
+ assert_equal [3], issue.watcher_user_ids
+ end
+
+ def test_create_as_copy_without_watcher_user_ids_should_not_copy_watchers
+ @request.session[:user_id] = 2
+ copied = Issue.generate!
+ copied.add_watcher User.find(2)
+ copied.add_watcher User.find(3)
+
+ assert_difference 'Issue.count' do
+ post :create, :params => {
+ :project_id => 1,
+ :copy_from => copied.id,
+ :issue => {
+ :subject => 'Copy cleared watchers',
+ :watcher_user_ids => ['']
+ }
+ }
+ end
+ issue = Issue.order('id DESC').first
+ assert_equal [], issue.watcher_user_ids
+ end
+
def test_get_edit
@request.session[:user_id] = 2
get :edit, :params => {