]> source.dussan.org Git - redmine.git/commitdiff
Merged r22792 from trunk to 5.1-stable (#40410).
authorMarius Balteanu <marius.balteanu@zitec.com>
Mon, 29 Apr 2024 19:18:04 +0000 (19:18 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Mon, 29 Apr 2024 19:18:04 +0000 (19:18 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.1-stable@22798 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/watchers_helper.rb
test/functional/issues_controller_test.rb

index fa06794634e7345556dcc00375c98b60b1777e29..4fd6391ac990c89be6b256a794a113cde0c0969a 100644 (file)
@@ -74,7 +74,7 @@ module WatchersHelper
 
   def watchers_checkboxes(object, users, checked=nil)
     users.map do |user|
-      c = checked.nil? ? object.watched_by?(user) : checked
+      c = checked.nil? ? object.watcher_user_ids.include?(user.id) : checked
       tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil
       content_tag 'label', "#{tag} #{h(user)}".html_safe,
                   :id => "issue_watcher_user_ids_#{user.id}",
index cce8ddc625290f2acbc816074c74b743e7cca262..014a2d835e11c2fccb873aae50615a632e0878c0 100644 (file)
@@ -4778,6 +4778,24 @@ 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
+
+    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