Feature #30112 » 30112-stop-reminder-on-non-working-days-r22605.patch
app/models/mailer.rb | ||
---|---|---|
629 | 629 |
end |
630 | 630 |
end |
631 | 631 | |
632 |
non_working_week_days = Setting.non_working_week_days |
|
632 | 633 |
issues_by_assignee.each do |assignee, issues| |
633 | 634 |
if assignee.is_a?(User) && assignee.active? && issues.present? |
635 |
next if assignee.pref.no_reminders_on_non_working_days == '1' && non_working_week_days.include?("#{assignee.today.cwday}") |
|
634 | 636 |
visible_issues = issues.select {|i| i.visible?(assignee)} |
635 | 637 |
visible_issues.sort!{|a, b| (a.due_date <=> b.due_date).nonzero? || (a.id <=> b.id)} |
636 | 638 |
reminder(assignee, visible_issues, days).deliver_later if visible_issues.present? |
app/models/user_preference.rb | ||
---|---|---|
40 | 40 |
'default_issue_query', |
41 | 41 |
'default_project_query', |
42 | 42 |
'toolbar_language_options', |
43 |
'auto_watch_on') |
|
43 |
'auto_watch_on', |
|
44 |
'no_reminders_on_non_working_days') |
|
44 | 45 | |
45 | 46 |
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional'] |
46 | 47 |
DEFAULT_TOOLBAR_LANGUAGE_OPTIONS = %w[c cpp csharp css diff go groovy html java javascript objc perl php python r ruby sass scala shell sql swift xml yaml] |
... | ... | |
133 | 134 |
def auto_watch_on=(values); self[:auto_watch_on]=values; end |
134 | 135 |
def auto_watch_on?(action); self.auto_watch_on.include?(action.to_s); end |
135 | 136 | |
137 |
def no_reminders_on_non_working_days; self[:no_reminders_on_non_working_days]; end |
|
138 |
def no_reminders_on_non_working_days=(value); self[:no_reminders_on_non_working_days]=value; end |
|
139 | ||
136 | 140 |
# Returns the names of groups that are displayed on user's page |
137 | 141 |
# Example: |
138 | 142 |
# preferences.my_page_groups |
app/views/users/_mail_notifications.html.erb | ||
---|---|---|
35 | 35 |
<%= pref_fields.check_box :no_self_notified %> |
36 | 36 |
<label for="pref_no_self_notified"><%= l(:label_user_mail_no_self_notified) %></label> |
37 | 37 |
</p> |
38 |
<p> |
|
39 |
<%= pref_fields.check_box :no_reminders_on_non_working_days %> |
|
40 |
<label for="pref_no_reminders_on_non_working_days"><%= l(:label_user_mail_no_reminders_on_non_working_days) %></label> |
|
41 |
</p> |
|
38 | 42 |
<% end %> |
config/locales/en.yml | ||
---|---|---|
950 | 950 |
label_user_mail_option_only_owner: "Only for things I watch or I am the owner of" |
951 | 951 |
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself" |
952 | 952 |
label_user_mail_notify_about_high_priority_issues_html: "Also notify me about issues with a priority of <em>%{prio}</em> or higher" |
953 |
label_user_mail_no_reminders_on_non_working_days: "I don't want to receive email reminders on non-working days" |
|
953 | 954 |
label_registration_activation_by_email: account activation by email |
954 | 955 |
label_registration_manual_activation: manual account activation |
955 | 956 |
label_registration_automatic_activation: automatic account activation |
test/functional/users_controller_test.rb | ||
---|---|---|
492 | 492 |
'comments_sorting' => 'desc', |
493 | 493 |
'warn_on_leaving_unsaved' => '0', |
494 | 494 |
'textarea_font' => 'proportional', |
495 |
'history_default_tab' => 'history' |
|
495 |
'history_default_tab' => 'history', |
|
496 |
'no_reminders_on_non_working_days' => '1' |
|
496 | 497 |
} |
497 | 498 |
} |
498 | 499 |
end |
... | ... | |
504 | 505 |
assert_equal '0', user.pref[:warn_on_leaving_unsaved] |
505 | 506 |
assert_equal 'proportional', user.pref[:textarea_font] |
506 | 507 |
assert_equal 'history', user.pref[:history_default_tab] |
508 |
assert_equal '1', user.pref[:no_reminders_on_non_working_days] |
|
507 | 509 |
end |
508 | 510 | |
509 | 511 |
def test_create_with_generate_password_should_email_the_password |
... | ... | |
566 | 568 |
'hide_mail' => '1', |
567 | 569 |
'time_zone' => 'Paris', |
568 | 570 |
'comments_sorting' => 'desc', |
569 |
'warn_on_leaving_unsaved' => '0' |
|
571 |
'warn_on_leaving_unsaved' => '0', |
|
572 |
'no_reminders_on_non_working_days' => '1' |
|
570 | 573 |
} |
571 | 574 |
} |
572 | 575 |
end |
... | ... | |
574 | 577 | |
575 | 578 |
assert_select 'select#pref_time_zone option[selected=selected]', :text => /Paris/ |
576 | 579 |
assert_select 'input#pref_no_self_notified[value="1"][checked=checked]' |
580 |
assert_select 'input#pref_no_reminders_on_non_working_days[value="1"][checked=checked]' |
|
577 | 581 |
end |
578 | 582 | |
579 | 583 |
def test_create_admin_should_send_security_notification |
test/unit/mailer_test.rb | ||
---|---|---|
979 | 979 |
end |
980 | 980 |
end |
981 | 981 | |
982 |
def test_reminders_with_non_working_days |
|
983 |
user = User.find_by_login("dlopper") |
|
984 |
with_settings :non_working_week_days => %W(#{user.today.cwday}) do |
|
985 |
# Sending reminders to users who want to receive it on non-working days.(Default) |
|
986 |
user.pref.no_reminders_on_non_working_days = '0' |
|
987 |
user.pref.save! |
|
988 |
ActionMailer::Base.deliveries.clear |
|
989 |
Mailer.reminders(:users => [user.id]) |
|
990 |
assert_equal 1, ActionMailer::Base.deliveries.size |
|
991 | ||
992 |
# Not sending reminders to users who not want to receive it on non-working days. |
|
993 |
user.pref.no_reminders_on_non_working_days = '1' |
|
994 |
user.pref.save! |
|
995 |
ActionMailer::Base.deliveries.clear |
|
996 |
Mailer.reminders(:users => [user.id]) |
|
997 |
assert_equal 0, ActionMailer::Base.deliveries.size |
|
998 |
end |
|
999 |
end |
|
1000 | ||
982 | 1001 |
def test_security_notification |
983 | 1002 |
set_language_if_valid User.find(1).language |
984 | 1003 |
with_settings :emails_footer => "footer without link" do |
- « Previous
- 1
- 2
- 3
- Next »