mirror of
https://github.com/redmine/redmine.git
synced 2026-04-02 02:31:17 +02:00
Add a mail notification option for watched objects only (#37978).
Patch by Go MAEDA (user:maeda). git-svn-id: https://svn.redmine.org/redmine/trunk@24523 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -89,6 +89,7 @@ class User < Principal
|
||||
['only_my_events', :label_user_mail_option_only_my_events],
|
||||
['only_assigned', :label_user_mail_option_only_assigned],
|
||||
['only_owner', :label_user_mail_option_only_owner],
|
||||
['only_my_watches', :label_user_mail_option_only_my_watches],
|
||||
['none', :label_user_mail_option_none]
|
||||
]
|
||||
|
||||
@@ -876,6 +877,8 @@ class User < Principal
|
||||
is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.previous_assignee)
|
||||
when 'only_owner'
|
||||
object.author == self
|
||||
when 'only_my_watches'
|
||||
object.watched_by?(self)
|
||||
end
|
||||
when News
|
||||
# always send to project members except when mail_notification is set to 'none'
|
||||
|
||||
@@ -975,6 +975,7 @@ en:
|
||||
label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in"
|
||||
label_user_mail_option_only_assigned: "Only for things I watch or I am assigned to"
|
||||
label_user_mail_option_only_owner: "Only for things I watch or I am the owner of"
|
||||
label_user_mail_option_only_my_watches: "Only for things I watch"
|
||||
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||||
label_user_mail_notify_about_high_priority_issues_html: "Also notify me about issues with a priority of <em>%{prio}</em> or higher"
|
||||
label_registration_activation_by_email: Self account activation by email verification
|
||||
|
||||
@@ -471,6 +471,28 @@ class MailerTest < ActiveSupport::TestCase
|
||||
assert_include user.mail, recipients
|
||||
end
|
||||
|
||||
test "#issue_add should notify issue watchers with only_my_watches mail notification" do
|
||||
issue = Issue.find(1)
|
||||
user = User.find(9)
|
||||
user.mail_notification = 'only_my_watches'
|
||||
user.save!
|
||||
|
||||
Watcher.create!(:watchable => issue, :user => user)
|
||||
assert Mailer.deliver_issue_add(issue)
|
||||
assert_include user.mail, recipients
|
||||
end
|
||||
|
||||
test "#issue_add should not notify the author with only_my_watches mail notification unless watched" do
|
||||
author = User.find(1)
|
||||
author.mail_notification = 'only_my_watches'
|
||||
author.save!
|
||||
|
||||
issue = Issue.generate!(project_id: 1, author: author)
|
||||
|
||||
assert Mailer.deliver_issue_add(issue)
|
||||
assert_not_include author.mail, recipients
|
||||
end
|
||||
|
||||
test "#issue_add should not notify watchers not allowed to view the issue" do
|
||||
issue = Issue.find(1)
|
||||
user = User.find(9)
|
||||
|
||||
@@ -1089,15 +1089,15 @@ class UserTest < ActiveSupport::TestCase
|
||||
|
||||
def test_valid_notification_options
|
||||
# without memberships
|
||||
assert_equal 5, User.find(7).valid_notification_options.size
|
||||
assert_equal 6, User.find(7).valid_notification_options.size
|
||||
# with memberships
|
||||
assert_equal 6, User.find(2).valid_notification_options.size
|
||||
assert_equal 7, User.find(2).valid_notification_options.size
|
||||
end
|
||||
|
||||
def test_valid_notification_options_class_method
|
||||
assert_equal 5, User.valid_notification_options.size
|
||||
assert_equal 5, User.valid_notification_options(User.find(7)).size
|
||||
assert_equal 6, User.valid_notification_options(User.find(2)).size
|
||||
assert_equal 6, User.valid_notification_options.size
|
||||
assert_equal 6, User.valid_notification_options(User.find(7)).size
|
||||
assert_equal 7, User.valid_notification_options(User.find(2)).size
|
||||
end
|
||||
|
||||
def test_notified_project_ids_setter_should_coerce_to_unique_integer_array
|
||||
|
||||
Reference in New Issue
Block a user