Project

General

Profile

Defect #40555 ยป checked_only_submitted.patch

Kenta Kumojima, 2024-04-12 16:29

View differences:

app/helpers/watchers_helper.rb
74 74

  
75 75
  def watchers_checkboxes(object, users, checked=nil)
76 76
    users.map do |user|
77
      c = checked.nil? ? object.watched_by?(user) : checked
77
      c = checked.nil? ? object.watcher_user_ids.include?(user.id) : checked
78 78
      tag = check_box_tag 'issue[watcher_user_ids][]', user.id, c, :id => nil
79 79
      content_tag 'label', "#{tag} #{h(user)}".html_safe,
80 80
                  :id => "issue_watcher_user_ids_#{user.id}",
test/functional/issues_controller_test.rb
4778 4778
    assert_select 'input[name=?][value="8"][checked=checked]', 'issue[watcher_user_ids][]'
4779 4779
  end
4780 4780

  
4781
  def test_post_create_with_failure_should_not_dereference_group_watchers
4782
    @request.session[:user_id] = 1
4783
    post(
4784
      :create,
4785
      :params => {
4786
        :project_id => 5,
4787
        :issue => {
4788
          :tracker_id => 1,
4789
          :watcher_user_ids => ['11']
4790
        }
4791
      }
4792
    )
4793
    assert_response :success
4794

  
4795
    assert_select 'input[name=?][value="8"][checked=checked]', 'issue[watcher_user_ids][]', 0
4796
    assert_select 'input[name=?][value="11"][checked=checked]', 'issue[watcher_user_ids][]', 1
4797
  end
4798

  
4781 4799
  def test_post_create_should_ignore_non_safe_attributes
4782 4800
    @request.session[:user_id] = 2
4783 4801
    assert_nothing_raised do
    (1-1/1)