summaryrefslogtreecommitdiffstats
path: root/test/unit/user_test.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-28 18:22:10 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-28 18:22:10 +0000
commitc059300d99aa439c83372a950087f082c7049018 (patch)
tree89d2f0a4f62879365cb1223252661fbeb386de80 /test/unit/user_test.rb
parenta61ee73e691fcc3bc8331cee778e93e5f82884ce (diff)
downloadredmine-c059300d99aa439c83372a950087f082c7049018.tar.gz
redmine-c059300d99aa439c83372a950087f082c7049018.zip
Added User#notify_about? to check when a user should be notified about an event
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4218 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/user_test.rb')
-rw-r--r--test/unit/user_test.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 1ecbc5927..07dada4e7 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -398,6 +398,72 @@ class UserTest < ActiveSupport::TestCase
end
end
+ context "User#notify_about?" do
+ context "Issues" do
+ setup do
+ @project = Project.find(1)
+ @author = User.generate_with_protected!
+ @assignee = User.generate_with_protected!
+ @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
+ end
+
+ should "be true for a user with :all" do
+ @author.update_attribute(:mail_notification, :all)
+ assert @author.notify_about?(@issue)
+ end
+
+ should "be false for a user with :none" do
+ @author.update_attribute(:mail_notification, :none)
+ assert ! @author.notify_about?(@issue)
+ end
+
+ 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)
+ assert ! @user.notify_about?(@issue)
+ end
+
+ should "be true for a user with :only_my_events and is the author" do
+ @author.update_attribute(:mail_notification, :only_my_events)
+ assert @author.notify_about?(@issue)
+ end
+
+ should "be true for a user with :only_my_events and is the assignee" do
+ @assignee.update_attribute(:mail_notification, :only_my_events)
+ assert @assignee.notify_about?(@issue)
+ end
+
+ should "be true for a user with :only_assigned and is the assignee" do
+ @assignee.update_attribute(:mail_notification, :only_assigned)
+ assert @assignee.notify_about?(@issue)
+ end
+
+ should "be false for a user with :only_assigned and is not the assignee" do
+ @author.update_attribute(:mail_notification, :only_assigned)
+ assert ! @author.notify_about?(@issue)
+ end
+
+ should "be true for a user with :only_owner and is the author" do
+ @author.update_attribute(:mail_notification, :only_owner)
+ assert @author.notify_about?(@issue)
+ end
+
+ should "be false for a user with :only_owner and is not the author" do
+ @assignee.update_attribute(:mail_notification, :only_owner)
+ assert ! @assignee.notify_about?(@issue)
+ end
+
+ should "be false if the mail_notification is anything else" do
+ @assignee.update_attribute(:mail_notification, :somthing_else)
+ assert ! @assignee.notify_about?(@issue)
+ end
+
+ end
+
+ context "other events" do
+ should 'be added and tested'
+ end
+ end
+
if Object.const_defined?(:OpenID)
def test_setting_identity_url