Project

General

Profile

Defect #33935 ยป fixed-33935.patch

Yuichi HARADA, 2020-09-01 02:51

View differences:

lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb
73 73

  
74 74
        def notified_watchers
75 75
          notified = watcher_users.active.to_a
76
          notified = notified.map {|n| n.is_a?(Group) ? n.users : n}.flatten
76
          notified = notified.map {|n| n.is_a?(Group) ? n.users.active : n}.flatten
77 77
          notified.uniq!
78 78
          notified.reject! {|user| user.mail.blank? || user.mail_notification == 'none'}
79 79
          if respond_to?(:visible?)
test/unit/mailer_test.rb
30 30
           :issue_statuses, :enumerations, :messages, :boards, :repositories,
31 31
           :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions,
32 32
           :versions,
33
           :comments
33
           :comments,
34
           :groups_users, :watchers
34 35

  
35 36
  def setup
36 37
    ActionMailer::Base.deliveries.clear
......
392 393
    Time.zone = zone_was
393 394
  end
394 395

  
396
  def test_locked_user_of_group_members_in_watchers_should_not_send_notification
397
    user = users(:users_005)  # Locked user
398
    group = Group.generate!
399
    group.users << user
400
    issue = Issue.generate!
401
    Watcher.create!(:watchable => issue, :user => group)
402

  
403
    ActionMailer::Base.deliveries.clear
404
    assert Mailer.deliver_issue_add(issue)
405
    assert_not_include user.mail, recipients
406

  
407
    journal = issue.init_journal(User.current)
408
    issue.update(:status_id => 4)
409
    ActionMailer::Base.deliveries.clear
410
    Mailer.deliver_issue_edit(journal)
411
    assert_not_include user.mail, recipients
412
  end
413

  
395 414
  test "#issue_add should notify project members" do
396 415
    issue = Issue.find(1)
397 416
    assert Mailer.deliver_issue_add(issue)
    (1-1/1)