summaryrefslogtreecommitdiffstats
path: root/test/unit/user_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-24 21:08:03 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-11-24 21:08:03 +0000
commitee8e7a4e33616e6a0d2c881213c648eaf9a67713 (patch)
tree7b8856646cf6237a6c20a5cd52b18911f27f8b89 /test/unit/user_test.rb
parent8127b2b4bdef1b537097cefe05a399e34aec0bd3 (diff)
downloadredmine-ee8e7a4e33616e6a0d2c881213c648eaf9a67713.tar.gz
redmine-ee8e7a4e33616e6a0d2c881213c648eaf9a67713.zip
Added missing tests for notify_about?
git-svn-id: http://svn.redmine.org/redmine/trunk@13650 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit/user_test.rb')
-rw-r--r--test/unit/user_test.rb51
1 files changed, 27 insertions, 24 deletions
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 0ebbb532e..b41703ec1 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -1084,7 +1084,7 @@ class UserTest < ActiveSupport::TestCase
assert_equal true, @anonymous.allowed_to_globally?(:view_issues)
end
- def test_notify_about_for_issue
+ def test_notify_about_issue
project = Project.find(1)
author = User.generate!
assignee = User.generate!
@@ -1092,32 +1092,35 @@ class UserTest < ActiveSupport::TestCase
Member.create!(:user => member, :project => project, :role_ids => [1])
issue = Issue.generate!(:project => project, :assigned_to => assignee, :author => author)
- author.mail_notification = 'all'
- assert author.notify_about?(issue)
- author.mail_notification = 'only_my_events'
- assert author.notify_about?(issue)
- author.mail_notification = 'only_owner'
- assert author.notify_about?(issue)
- author.mail_notification = 'selected'
- assert author.notify_about?(issue)
- author.mail_notification = 'none'
- assert !author.notify_about?(issue)
-
- assignee.mail_notification = 'only_my_events'
- assert assignee.notify_about?(issue)
- assignee.mail_notification = 'only_owner'
- assert !assignee.notify_about?(issue)
- assignee.mail_notification = 'only_assigned'
+ tests = {
+ author => %w(all only_my_events only_owner selected),
+ assignee => %w(all only_my_events only_assigned selected),
+ member => %w(all)
+ }
+
+ tests.each do |user, expected|
+ User::MAIL_NOTIFICATION_OPTIONS.map(&:first).each do |option|
+ user.mail_notification = option
+ assert_equal expected.include?(option), user.notify_about?(issue)
+ end
+ end
+ end
+
+ def test_notify_about_issue_for_previous_assignee
+ assignee = User.generate!(:mail_notification => 'only_assigned')
+ new_assignee = User.generate!(:mail_notification => 'only_assigned')
+ issue = Issue.generate!(:assigned_to => assignee)
+
assert assignee.notify_about?(issue)
- assignee.mail_notification = 'selected'
+ assert !new_assignee.notify_about?(issue)
+
+ issue.assigned_to = new_assignee
assert assignee.notify_about?(issue)
+ assert new_assignee.notify_about?(issue)
- member.mail_notification = 'only_my_events'
- assert !member.notify_about?(issue)
- member.mail_notification = 'only_assigned'
- assert !member.notify_about?(issue)
- member.mail_notification = 'selected'
- assert !member.notify_about?(issue)
+ issue.save!
+ assert !assignee.notify_about?(issue)
+ assert new_assignee.notify_about?(issue)
end
def test_notify_about_news