From 5220a429facf1c79803d6e4827dcfd7296dc5f39 Mon Sep 17 00:00:00 2001 From: kumojima Date: Thu, 11 Apr 2024 15:02:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E5=86=8D?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E6=99=82=E3=81=AB=E3=82=B0=E3=83=AB=E3=83=BC?= =?UTF-8?q?=E3=83=97=E3=81=AB=E5=B1=9E=E3=81=99=E3=82=8B=E3=83=A6=E3=83=BC?= =?UTF-8?q?=E3=82=B6=E3=83=BC=E3=81=AB=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=81=8C=E5=85=A5=E3=82=89=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/watchers_helper.rb | 2 +- test/functional/issues_controller_test.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 0bbd8fcabf..d6bbe87cdd 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -74,7 +74,7 @@ def watchers_list(object) 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}", diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index ee477dffa8..2e91c0bc58 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -4778,6 +4778,24 @@ def test_post_create_with_failure_should_preserve_watchers 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