]> source.dussan.org Git - redmine.git/commitdiff
Fixed: no email sent with 'Notifiy for any event on the selected projects only' ...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 24 Jan 2011 17:28:59 +0000 (17:28 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 24 Jan 2011 17:28:59 +0000 (17:28 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4761 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb
test/unit/user_test.rb

index 3cc6b8e40e53e30293a02043d8a554db88e29617..5b0444016e06b9a1793013440da217a59c119536 100644 (file)
@@ -424,7 +424,12 @@ class User < Principal
     when 'all'
       true
     when 'selected'
-      # Handled by the Project
+      # user receives notifications for created/assigned issues on unselected projects
+      if object.is_a?(Issue) && (object.author == self || object.assigned_to == self)
+        true
+      else
+        false
+      end
     when 'none'
       false
     when 'only_my_events'
index bf5b45a60a2922c7dfe421ca2a5895ab0c07e52c..63e422701e3e5d24ab545e74c5ab4f7105f37457 100644 (file)
@@ -672,6 +672,7 @@ class UserTest < ActiveSupport::TestCase
       
       should "be false for a user with :only_my_events and isn't an author, creator, or assignee" do
         @user = User.generate_with_protected!(:mail_notification => 'only_my_events')
+        Member.create!(:user => @user, :project => @project, :role_ids => [1])
         assert ! @user.notify_about?(@issue)
       end
       
@@ -704,6 +705,22 @@ class UserTest < ActiveSupport::TestCase
         @assignee.update_attribute(:mail_notification, 'only_owner')
         assert ! @assignee.notify_about?(@issue)
       end
+      
+      should "be true for a user with :selected and is the author" do
+        @author.update_attribute(:mail_notification, 'selected')
+        assert @author.notify_about?(@issue)
+      end
+      
+      should "be true for a user with :selected and is the assignee" do
+        @assignee.update_attribute(:mail_notification, 'selected')
+        assert @assignee.notify_about?(@issue)
+      end
+      
+      should "be false for a user with :selected and is not the author or assignee" do
+        @user = User.generate_with_protected!(:mail_notification => 'selected')
+        Member.create!(:user => @user, :project => @project, :role_ids => [1])
+        assert ! @user.notify_about?(@issue)
+      end
     end
 
     context "other events" do