Project

General

Profile

Actions

Defect #40410

closed

Watcher groups on new issue form get dereferenced on validation error

Added by Felix Schäfer 8 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Category:
Issues
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

When creating a new issue, selecting a group as a watcher and causing a validation error (for example leave the subject blank), all users of the group will be selected in addition to the initially selected group.

This test shows the problem:

diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index cce8ddc625..fb401c701d 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -4778,6 +4778,25 @@ class IssuesControllerTest < Redmine::ControllerTest
     assert_select 'input[name=?][value="8"][checked=checked]', 'issue[watcher_user_ids][]'
   end

+  def test_post_create_with_failure_should_not_dereference_group_watchers
+    @request.session[:user_id] = 1
+    post(
+      :create,
+      :params => {
+        :project_id => 5,
+        :issue => {
+          :tracker_id => 1,
+          :watcher_user_ids => ['11']
+        }
+      }
+    )
+    assert_response :success
+
+    # The group's user was not explicitely selected
+    assert_select 'input[name=?][value="8"][checked=checked]', 'issue[watcher_user_ids][]', 0
+    assert_select 'input[name=?][value="11"][checked=checked]', 'issue[watcher_user_ids][]', 1
+  end
+
   def test_post_create_should_ignore_non_safe_attributes
     @request.session[:user_id] = 2
     assert_nothing_raised do

(Please note: The test above the one proposed in the diff uses the :not(checked) pseudo-selector, this however does not seem to work as expected)


Related issues

Related to Redmine - Feature #4511: Allow adding user groups as watchers for issuesClosedGo MAEDA2010-01-01

Actions
Has duplicate Redmine - Defect #40555: Watcher group checkbox on new issue form on validation error will be checked only submittedClosedMarius BĂLTEANU

Actions
Actions

Also available in: Atom PDF