Project

General

Profile

Actions

Defect #40410

closed

Watcher groups on new issue form get dereferenced on validation error

Added by Felix Schäfer 2 months ago. Updated 17 days 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 #1

Updated by Marius BĂLTEANU 18 days ago

  • Has duplicate Defect #40555: Watcher group checkbox on new issue form on validation error will be checked only submitted added
Actions #2

Updated by Marius BĂLTEANU 18 days ago

  • Status changed from New to Resolved
  • Assignee set to Marius BĂLTEANU
  • Target version set to 5.0.9
  • Resolution set to Fixed

I've committed the fix from #40410, thanks for reporting and for the test.

Actions #3

Updated by Marius BĂLTEANU 18 days ago

  • Related to Feature #4511: Allow adding user groups as watchers for issues added
Actions #4

Updated by Marius BĂLTEANU 17 days ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF