Feature #30112 » 30112-stop-reminder-on-non-working-days.patch
| app/models/mailer.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
non_working_week_days = Setting.non_working_week_days
|
||
|
issues_by_assignee.each do |assignee, issues|
|
||
|
if assignee.is_a?(User) && assignee.active? && issues.present?
|
||
|
next if assignee.pref.no_reminders_on_non_working_days == '1' && non_working_week_days.include?("#{assignee.today.cwday}")
|
||
|
visible_issues = issues.select {|i| i.visible?(assignee)}
|
||
|
visible_issues.sort!{|a, b| (a.due_date <=> b.due_date).nonzero? || (a.id <=> b.id)}
|
||
|
reminder(assignee, visible_issues, days).deliver_later if visible_issues.present?
|
||
| app/models/user_preference.rb | ||
|---|---|---|
|
'comments_sorting',
|
||
|
'warn_on_leaving_unsaved',
|
||
|
'no_self_notified',
|
||
|
'textarea_font'
|
||
|
'textarea_font',
|
||
|
'no_reminders_on_non_working_days'
|
||
|
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def comments_sorting; self[:comments_sorting] end
|
||
|
def comments_sorting=(order); self[:comments_sorting]=order end
|
||
|
def comments_sorting; self[:comments_sorting]; end
|
||
|
def comments_sorting=(order); self[:comments_sorting]=order; end
|
||
|
def warn_on_leaving_unsaved; self[:warn_on_leaving_unsaved] || '1'; end
|
||
|
def warn_on_leaving_unsaved=(value); self[:warn_on_leaving_unsaved]=value; end
|
||
| ... | ... | |
|
def no_self_notified; (self[:no_self_notified] == true || self[:no_self_notified] == '1'); end
|
||
|
def no_self_notified=(value); self[:no_self_notified]=value; end
|
||
|
def activity_scope; Array(self[:activity_scope]) ; end
|
||
|
def activity_scope=(value); self[:activity_scope]=value ; end
|
||
|
def activity_scope; Array(self[:activity_scope]); end
|
||
|
def activity_scope=(value); self[:activity_scope]=value; end
|
||
|
def textarea_font; self[:textarea_font] end
|
||
|
def textarea_font; self[:textarea_font]; end
|
||
|
def textarea_font=(value); self[:textarea_font]=value; end
|
||
|
def no_reminders_on_non_working_days; self[:no_reminders_on_non_working_days]; end
|
||
|
def no_reminders_on_non_working_days=(value); self[:no_reminders_on_non_working_days]=value; end
|
||
|
# Returns the names of groups that are displayed on user's page
|
||
|
# Example:
|
||
|
# preferences.my_page_groups
|
||
| app/views/users/_mail_notifications.html.erb | ||
|---|---|---|
|
<%= content_tag 'fieldset', :id => 'notified-projects', :style => (@user.mail_notification == 'selected' ? '' : 'display:none;') do %>
|
||
|
<legend><%= toggle_checkboxes_link("#notified-projects input[type=checkbox]") %><%=l(:label_project_plural)%></legend>
|
||
|
<%= render_project_nested_lists(@user.projects) do |project|
|
||
|
content_tag('label',
|
||
|
content_tag('label',
|
||
|
check_box_tag(
|
||
|
'user[notified_project_ids][]',
|
||
|
project.id,
|
||
| ... | ... | |
|
<%= pref_fields.check_box :no_self_notified %>
|
||
|
<label for="pref_no_self_notified"><%= l(:label_user_mail_no_self_notified) %></label>
|
||
|
</p>
|
||
|
<p>
|
||
|
<%= pref_fields.check_box :no_reminders_on_non_working_days %>
|
||
|
<label for="pref_no_reminders_on_non_working_days"><%= l(:label_user_mail_no_reminders_on_non_working_days) %></label>
|
||
|
</p>
|
||
|
<% end %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
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_no_self_notified: "I don't want to be notified of changes that I make myself"
|
||
|
label_user_mail_no_reminders_on_non_working_days: "I don't want to receive email reminders on non-working days"
|
||
|
label_registration_activation_by_email: account activation by email
|
||
|
label_registration_manual_activation: manual account activation
|
||
|
label_registration_automatic_activation: automatic account activation
|
||
| test/functional/users_controller_test.rb | ||
|---|---|---|
|
'time_zone' => 'Paris',
|
||
|
'comments_sorting' => 'desc',
|
||
|
'warn_on_leaving_unsaved' => '0',
|
||
|
'textarea_font' => 'proportional'
|
||
|
'textarea_font' => 'proportional',
|
||
|
'no_reminders_on_non_working_days' => '1'
|
||
|
}
|
||
|
}
|
||
|
end
|
||
| ... | ... | |
|
assert_equal 'desc', user.pref[:comments_sorting]
|
||
|
assert_equal '0', user.pref[:warn_on_leaving_unsaved]
|
||
|
assert_equal 'proportional', user.pref[:textarea_font]
|
||
|
assert_equal '1', user.pref[:no_reminders_on_non_working_days]
|
||
|
end
|
||
|
def test_create_with_generate_password_should_email_the_password
|
||
| ... | ... | |
|
'hide_mail' => '1',
|
||
|
'time_zone' => 'Paris',
|
||
|
'comments_sorting' => 'desc',
|
||
|
'warn_on_leaving_unsaved' => '0'
|
||
|
'warn_on_leaving_unsaved' => '0',
|
||
|
'no_reminders_on_non_working_days' => '1'
|
||
|
}
|
||
|
}
|
||
|
end
|
||
| ... | ... | |
|
assert_select 'select#pref_time_zone option[selected=selected]', :text => /Paris/
|
||
|
assert_select 'input#pref_no_self_notified[value="1"][checked=checked]'
|
||
|
assert_select 'input#pref_no_reminders_on_non_working_days[value="1"][checked=checked]'
|
||
|
end
|
||
|
def test_create_admin_should_send_security_notification
|
||
| test/unit/mailer_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_reminders_with_non_working_days
|
||
|
user = User.find_by_login("dlopper")
|
||
|
with_settings :non_working_week_days => %W(#{user.today.cwday}) do
|
||
|
# Sending reminders to users who want to receive it on non-working days.(Default)
|
||
|
user.pref.no_reminders_on_non_working_days = '0'
|
||
|
user.pref.save!
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
Mailer.reminders(:users => [user.id])
|
||
|
assert_equal 1, ActionMailer::Base.deliveries.size
|
||
|
# Not sending reminders to users who not want to receive it on non-working days.
|
||
|
user.pref.no_reminders_on_non_working_days = '1'
|
||
|
user.pref.save!
|
||
|
ActionMailer::Base.deliveries.clear
|
||
|
Mailer.reminders(:users => [user.id])
|
||
|
assert_equal 0, ActionMailer::Base.deliveries.size
|
||
|
end
|
||
|
end
|
||
|
def test_security_notification
|
||
|
set_language_if_valid User.find(1).language
|
||
|
with_settings :emails_footer => "footer without link" do
|
||