Feature #37978 » 0001-New-email-notification-option-Only-for-things-I-watc.patch
| app/models/user.rb | ||
|---|---|---|
| 89 | 89 |
['only_my_events', :label_user_mail_option_only_my_events], |
| 90 | 90 |
['only_assigned', :label_user_mail_option_only_assigned], |
| 91 | 91 |
['only_owner', :label_user_mail_option_only_owner], |
| 92 |
['only_my_watches', :label_user_mail_option_only_my_watches], |
|
| 92 | 93 |
['none', :label_user_mail_option_none] |
| 93 | 94 |
] |
| 94 | 95 | |
| ... | ... | |
| 870 | 871 |
is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.previous_assignee) |
| 871 | 872 |
when 'only_owner' |
| 872 | 873 |
object.author == self |
| 874 |
when 'only_my_watches' |
|
| 875 |
object.watched_by?(self) |
|
| 873 | 876 |
end |
| 874 | 877 |
when News |
| 875 | 878 |
# always send to project members except when mail_notification is set to 'none' |
| config/locales/en.yml | ||
|---|---|---|
| 975 | 975 |
label_user_mail_option_only_my_events: "Only for things I watch or I'm involved in" |
| 976 | 976 |
label_user_mail_option_only_assigned: "Only for things I watch or I am assigned to" |
| 977 | 977 |
label_user_mail_option_only_owner: "Only for things I watch or I am the owner of" |
| 978 |
label_user_mail_option_only_my_watches: "Only for things I watch" |
|
| 978 | 979 |
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself" |
| 979 | 980 |
label_user_mail_notify_about_high_priority_issues_html: "Also notify me about issues with a priority of <em>%{prio}</em> or higher"
|
| 980 | 981 |
label_registration_activation_by_email: Self account activation by email verification |
| test/unit/mailer_test.rb | ||
|---|---|---|
| 471 | 471 |
assert_include user.mail, recipients |
| 472 | 472 |
end |
| 473 | 473 | |
| 474 |
test "#issue_add should notify issue watchers with only_my_watches mail notification" do |
|
| 475 |
issue = Issue.find(1) |
|
| 476 |
user = User.find(9) |
|
| 477 |
user.mail_notification = 'only_my_watches' |
|
| 478 |
user.save! |
|
| 479 | ||
| 480 |
Watcher.create!(:watchable => issue, :user => user) |
|
| 481 |
assert Mailer.deliver_issue_add(issue) |
|
| 482 |
assert_include user.mail, recipients |
|
| 483 |
end |
|
| 484 | ||
| 485 |
test "#issue_add should not notify the author with only_my_watches mail notification unless watched" do |
|
| 486 |
author = User.find(1) |
|
| 487 |
author.mail_notification = 'only_my_watches' |
|
| 488 |
author.save! |
|
| 489 | ||
| 490 |
issue = Issue.generate!(project_id: 1, author: author) |
|
| 491 | ||
| 492 |
assert Mailer.deliver_issue_add(issue) |
|
| 493 |
assert_not_include author.mail, recipients |
|
| 494 |
end |
|
| 495 | ||
| 474 | 496 |
test "#issue_add should not notify watchers not allowed to view the issue" do |
| 475 | 497 |
issue = Issue.find(1) |
| 476 | 498 |
user = User.find(9) |
| test/unit/user_test.rb | ||
|---|---|---|
| 1089 | 1089 | |
| 1090 | 1090 |
def test_valid_notification_options |
| 1091 | 1091 |
# without memberships |
| 1092 |
assert_equal 5, User.find(7).valid_notification_options.size
|
|
| 1092 |
assert_equal 6, User.find(7).valid_notification_options.size
|
|
| 1093 | 1093 |
# with memberships |
| 1094 |
assert_equal 6, User.find(2).valid_notification_options.size
|
|
| 1094 |
assert_equal 7, User.find(2).valid_notification_options.size
|
|
| 1095 | 1095 |
end |
| 1096 | 1096 | |
| 1097 | 1097 |
def test_valid_notification_options_class_method |
| 1098 |
assert_equal 5, User.valid_notification_options.size
|
|
| 1099 |
assert_equal 5, User.valid_notification_options(User.find(7)).size
|
|
| 1100 |
assert_equal 6, User.valid_notification_options(User.find(2)).size
|
|
| 1098 |
assert_equal 6, User.valid_notification_options.size
|
|
| 1099 |
assert_equal 6, User.valid_notification_options(User.find(7)).size
|
|
| 1100 |
assert_equal 7, User.valid_notification_options(User.find(2)).size
|
|
| 1101 | 1101 |
end |
| 1102 | 1102 | |
| 1103 | 1103 |
def test_notified_project_ids_setter_should_coerce_to_unique_integer_array |
- « Previous
- 1
- 2
- Next »