Browse Source

Locked users in a group receive notifications when the group is added as a watcher (#4511, #33935).

Patch by Yuichi HARADA.


git-svn-id: http://svn.redmine.org/redmine/trunk@19998 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.2.0
Go MAEDA 3 years ago
parent
commit
b0739821e8
2 changed files with 21 additions and 2 deletions
  1. 1
    1
      lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb
  2. 20
    1
      test/unit/mailer_test.rb

+ 1
- 1
lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb View File

@@ -73,7 +73,7 @@ module Redmine

def notified_watchers
notified = watcher_users.active.to_a
notified = notified.map {|n| n.is_a?(Group) ? n.users : n}.flatten
notified = notified.map {|n| n.is_a?(Group) ? n.users.active : n}.flatten
notified.uniq!
notified.reject! {|user| user.mail.blank? || user.mail_notification == 'none'}
if respond_to?(:visible?)

+ 20
- 1
test/unit/mailer_test.rb View File

@@ -30,7 +30,8 @@ class MailerTest < ActiveSupport::TestCase
:issue_statuses, :enumerations, :messages, :boards, :repositories,
:wikis, :wiki_pages, :wiki_contents, :wiki_content_versions,
:versions,
:comments
:comments,
:groups_users, :watchers

def setup
ActionMailer::Base.deliveries.clear
@@ -602,6 +603,24 @@ class MailerTest < ActiveSupport::TestCase
end
end

def test_locked_user_in_group_watcher_should_not_be_notified
locked_user = users(:users_005)
group = Group.generate!
group.users << locked_user
issue = Issue.generate!
Watcher.create!(:watchable => issue, :user => group)

ActionMailer::Base.deliveries.clear
assert Mailer.deliver_issue_add(issue)
assert_not_include locked_user.mail, recipients

journal = issue.init_journal(User.current)
issue.update(:status_id => 4)
ActionMailer::Base.deliveries.clear
Mailer.deliver_issue_edit(journal)
assert_not_include locked_user.mail, recipients
end

def test_version_file_added
attachements = [ Attachment.find_by_container_type('Version') ]
assert Mailer.deliver_attachments_added(attachements)

Loading…
Cancel
Save