]> source.dussan.org Git - redmine.git/commitdiff
Add a default mail notification setting for new users
authorEric Davis <edavis@littlestreamsoftware.com>
Tue, 28 Sep 2010 18:36:50 +0000 (18:36 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Tue, 28 Sep 2010 18:36:50 +0000 (18:36 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4219 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb
app/views/settings/_notifications.rhtml
config/locales/en.yml
config/settings.yml
test/unit/user_test.rb

index 281e712817fe47107d5439a5a709360e64338469..0ac5e7d638442510c32875348b0a006a96deed44 100644 (file)
@@ -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
   
index cb1c1abf15eea8053049193b7b329396b62e0cbc..2c62cdf9f485b3d8a0d5eaa3d5884ac01b502580 100644 (file)
@@ -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>
index 48425c4fff1fbf590f98b01e058e256649d41bc6..879a309fab1a9548aec84dbd3fe89fcf24d0e51f 100644 (file)
@@ -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
index d07261f8f5ff85fdacc862e6b4ea7d8daa484088..e5ce1a0f941e34d6d025bdc4300d4189724bee9e 100644 (file)
@@ -184,3 +184,5 @@ start_of_week:
   default: ''
 rest_api_enabled:
   default: 0
+default_notification_option:
+  default: 'only_my_events'
index 07dada4e7260c9c13b66a4cbe5ce5ba7ab000fae..f3e56ddd3c65134b0fbb4371941932f9f20d7e32 100644 (file)
@@ -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