summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-16 15:36:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-16 15:36:42 +0000
commite17fadd07ac34f96a10a8b1e77b9ee06bc4149b2 (patch)
tree14642fe9523caed2bf41fcd5d1abda8cfef65ebb
parente9f62d1209bfa81df33bcb390eb67ba4cab90c0a (diff)
downloadredmine-e17fadd07ac34f96a10a8b1e77b9ee06bc4149b2.tar.gz
redmine-e17fadd07ac34f96a10a8b1e77b9ee06bc4149b2.zip
Do not show "for only project I select" notification option on application settings form (#7294).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4730 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/user.rb8
-rw-r--r--app/views/settings/_notifications.rhtml2
-rw-r--r--test/unit/user_test.rb6
3 files changed, 13 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 5b107478d..3cc6b8e40 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -262,11 +262,15 @@ class User < Principal
notified_projects_ids
end
- # Only users that belong to more than 1 project can select projects for which they are notified
def valid_notification_options
+ self.class.valid_notification_options(self)
+ end
+
+ # Only users that belong to more than 1 project can select projects for which they are notified
+ def self.valid_notification_options(user=nil)
# Note that @user.membership.size would fail since AR ignores
# :include association option when doing a count
- if memberships.length < 1
+ if user.nil? || user.memberships.length < 1
MAIL_NOTIFICATION_OPTIONS.reject {|option| option.first == 'selected'}
else
MAIL_NOTIFICATION_OPTIONS
diff --git a/app/views/settings/_notifications.rhtml b/app/views/settings/_notifications.rhtml
index 4cc81c931..26c11ad9a 100644
--- a/app/views/settings/_notifications.rhtml
+++ b/app/views/settings/_notifications.rhtml
@@ -8,7 +8,7 @@
<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>
+<p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>
</div>
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 98a577ebb..bf5b45a60 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -514,6 +514,12 @@ class UserTest < ActiveSupport::TestCase
assert_equal 6, User.find(2).valid_notification_options.size
end
+ def test_valid_notification_options_class_method
+ assert_equal 5, User.valid_notification_options.size
+ assert_equal 5, User.valid_notification_options(User.find(7)).size
+ assert_equal 6, User.valid_notification_options(User.find(2)).size
+ end
+
def test_mail_notification_all
@jsmith.mail_notification = 'all'
@jsmith.notified_project_ids = []