Makes 'auto watch issues' default user settings configurable (#42880).

Patch by Jan Catrysse (user:jcatrysse).

git-svn-id: https://svn.redmine.org/redmine/trunk@23956 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2025-09-07 08:02:04 +00:00
parent 5aba17319d
commit 2d44c48657
4 changed files with 23 additions and 3 deletions

View File

@@ -59,7 +59,8 @@ class UserPreference < ApplicationRecord
self.no_self_notified = Setting.default_users_no_self_notified
end
unless attributes && attributes.key?(:auto_watch_on)
self.auto_watch_on = AUTO_WATCH_ON_OPTIONS
value = Setting.default_users_auto_watch_on
self.auto_watch_on = value.nil? ? AUTO_WATCH_ON_OPTIONS : value
end
end
self.others ||= {}

View File

@@ -20,6 +20,7 @@
<p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>
<p><%= setting_check_box :default_users_no_self_notified, :label => :label_user_mail_no_self_notified %></p>
<p><%= setting_select :default_users_time_zone, ActiveSupport::TimeZone.all.collect {|z| [ z.to_s, z.name ]}, :label => :field_time_zone, :blank => :label_none %></p>
<p><%= setting_multiselect :default_users_auto_watch_on, UserPreference::AUTO_WATCH_ON_OPTIONS.map {|o| [l("label_auto_watch_on_#{o}"), o]}, :label => :label_auto_watch_on %></p>
</div>
</fieldset>

View File

@@ -301,6 +301,11 @@ default_users_no_self_notified:
default: 1
default_users_time_zone:
default: ""
default_users_auto_watch_on:
serialized: true
default:
- issue_created
- issue_contributed_to
# encodings used to convert files content to UTF-8
# multiple values accepted, comma separated
repositories_encodings:

View File

@@ -56,8 +56,21 @@ class UserPreferenceTest < ActiveSupport::TestCase
end
def test_auto_watch_on_should_default_to_setting
preference = UserPreference.new
assert_equal %w[issue_created issue_contributed_to], preference.auto_watch_on
with_settings :default_users_auto_watch_on => ['issue_created'] do
preference = UserPreference.new
assert_equal ['issue_created'], preference.auto_watch_on
end
with_settings :default_users_auto_watch_on => [] do
preference = UserPreference.new
assert_equal [], preference.auto_watch_on
end
end
def test_auto_watch_on_should_default_to_options
with_settings :default_users_auto_watch_on => nil do
preference = UserPreference.new
assert_equal %w[issue_created issue_contributed_to], preference.auto_watch_on
end
end
def test_create