Project

General

Profile

Feature #30112 » 30112-stop-reminder-on-non-working-days-r22605.patch

Mizuki ISHIKAWA, 2024-01-12 05:44

View differences:

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
'default_issue_query',
'default_project_query',
'toolbar_language_options',
'auto_watch_on')
'auto_watch_on',
'no_reminders_on_non_working_days')
TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional']
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]
......
def auto_watch_on=(values); self[:auto_watch_on]=values; end
def auto_watch_on?(action); self.auto_watch_on.include?(action.to_s); 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
<%= 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_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_notify_about_high_priority_issues_html: "Also notify me about issues with a priority of <em>%{prio}</em> or higher"
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
'comments_sorting' => 'desc',
'warn_on_leaving_unsaved' => '0',
'textarea_font' => 'proportional',
'history_default_tab' => 'history'
'history_default_tab' => 'history',
'no_reminders_on_non_working_days' => '1'
}
}
end
......
assert_equal '0', user.pref[:warn_on_leaving_unsaved]
assert_equal 'proportional', user.pref[:textarea_font]
assert_equal 'history', user.pref[:history_default_tab]
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
(3-3/3)