diff options
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/views/settings/_notifications.rhtml | 3 | ||||
-rw-r--r-- | config/locales/en.yml | 1 | ||||
-rw-r--r-- | config/settings.yml | 2 | ||||
-rw-r--r-- | test/unit/user_test.rb | 12 |
5 files changed, 19 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 281e71281..0ac5e7d63 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,7 +74,7 @@ class User < Principal validates_confirmation_of :password, :allow_nil => true def before_create - self.mail_notification = 'only_my_events' + self.mail_notification = Setting.default_notification_option true end diff --git a/app/views/settings/_notifications.rhtml b/app/views/settings/_notifications.rhtml index cb1c1abf1..2c62cdf9f 100644 --- a/app/views/settings/_notifications.rhtml +++ b/app/views/settings/_notifications.rhtml @@ -7,6 +7,9 @@ <p><%= setting_check_box :bcc_recipients %></p> <p><%= setting_check_box :plain_text_mail %></p> + +<p><%= setting_select(:default_notification_option, User::MAIL_NOTIFICATION_OPTIONS.collect {|o| [l(o.last), o.first.to_s]}) %></p> + </div> <fieldset class="box settings" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend> diff --git a/config/locales/en.yml b/config/locales/en.yml index 48425c4ff..879a309fa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -350,6 +350,7 @@ en: setting_start_of_week: Start calendars on setting_rest_api_enabled: Enable REST web service setting_cache_formatted_text: Cache formatted text + setting_default_notification_option: Default notification option permission_add_project: Create project permission_add_subprojects: Create subprojects diff --git a/config/settings.yml b/config/settings.yml index d07261f8f..e5ce1a0f9 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -184,3 +184,5 @@ start_of_week: default: '' rest_api_enabled: default: 0 +default_notification_option: + default: 'only_my_events' diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 07dada4e7..f3e56ddd3 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -60,6 +60,18 @@ class UserTest < ActiveSupport::TestCase user.password, user.password_confirmation = "password", "password" assert user.save end + + context "User#before_create" do + should "set the mail_notification to the default Setting" do + @user1 = User.generate_with_protected! + assert_equal 'only_my_events', @user1.mail_notification + + with_settings :default_notification_option => 'all' do + @user2 = User.generate_with_protected! + assert_equal 'all', @user2.mail_notification + end + end + end context "User.login" do should "be case-insensitive." do |