0001-do-not-propose-locked-watchers-when-copying-an-issue.patch

Marius BALTEANU, 2018-05-14 23:28

Download (2.34 KB)

View differences:

app/helpers/issues_helper.rb
312 312
  # Returns an array of users that are proposed as watchers
313 313
  # on the new issue form
314 314
  def users_for_new_issue_watchers(issue)
315
    users = issue.watcher_users
315
    users = issue.watcher_users.select{|u| u.status == User::STATUS_ACTIVE}
316 316
    if issue.project.users.count <= 20
317 317
      users = (users + issue.project.users.sort).uniq
318 318
    end
test/functional/issues_controller_test.rb
3916 3916
    assert_select 'input[type=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
3917 3917
  end
3918 3918

  
3919
  def test_new_as_copy_should_not_propose_locked_watchers
3920
    @request.session[:user_id] = 2
3921

  
3922
    issue = Issue.find(1)
3923
    user = User.generate!
3924
    user2 = User.generate!
3925

  
3926
    Watcher.create!(:watchable => issue, :user => user)
3927
    Watcher.create!(:watchable => issue, :user => user2)
3928

  
3929
    user2.status = User::STATUS_LOCKED
3930
    user2.save!
3931
    get :new, :params => {
3932
        :project_id => 1,
3933
        :copy_from => 1
3934
      }
3935

  
3936
    assert_select 'input[type=checkbox][name=?][checked=checked]', 'issue[watcher_user_ids][]', 1
3937
    assert_select 'input[type=checkbox][name=?][checked=checked][value=?]', 'issue[watcher_user_ids][]', user.id.to_s
3938
    assert_select 'input[type=checkbox][name=?][checked=checked][value=?]', 'issue[watcher_user_ids][]', user2.id.to_s, 0
3939
    assert_select 'input[type=hidden][name=?][value=?]', 'issue[watcher_user_ids][]', '', 1
3940
  end
3941

  
3919 3942
  def test_new_as_copy_with_invalid_issue_should_respond_with_404
3920 3943
    @request.session[:user_id] = 2
3921 3944
    get :new, :params => {
3922
-