Feature #37978 » 0001-New-email-notification-option-Only-for-things-I-watc.patch
| app/models/user.rb | ||
|---|---|---|
|
['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]
|
||
|
]
|
||
| ... | ... | |
|
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'
|
||
| config/locales/en.yml | ||
|---|---|---|
|
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
|
||
| test/unit/mailer_test.rb | ||
|---|---|---|
|
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)
|
||
| test/unit/user_test.rb | ||
|---|---|---|
|
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
|
||