##// END OF EJS Templates
Added missing tests for notify_about?...
Jean-Philippe Lang -
r13268:ee8e7a4e3361
parent child
Show More
@@ -1084,7 +1084,7 class UserTest < ActiveSupport::TestCase
1084 1084 assert_equal true, @anonymous.allowed_to_globally?(:view_issues)
1085 1085 end
1086 1086
1087 def test_notify_about_for_issue
1087 def test_notify_about_issue
1088 1088 project = Project.find(1)
1089 1089 author = User.generate!
1090 1090 assignee = User.generate!
@@ -1092,32 +1092,35 class UserTest < ActiveSupport::TestCase
1092 1092 Member.create!(:user => member, :project => project, :role_ids => [1])
1093 1093 issue = Issue.generate!(:project => project, :assigned_to => assignee, :author => author)
1094 1094
1095 author.mail_notification = 'all'
1096 assert author.notify_about?(issue)
1097 author.mail_notification = 'only_my_events'
1098 assert author.notify_about?(issue)
1099 author.mail_notification = 'only_owner'
1100 assert author.notify_about?(issue)
1101 author.mail_notification = 'selected'
1102 assert author.notify_about?(issue)
1103 author.mail_notification = 'none'
1104 assert !author.notify_about?(issue)
1105
1106 assignee.mail_notification = 'only_my_events'
1107 assert assignee.notify_about?(issue)
1108 assignee.mail_notification = 'only_owner'
1109 assert !assignee.notify_about?(issue)
1110 assignee.mail_notification = 'only_assigned'
1095 tests = {
1096 author => %w(all only_my_events only_owner selected),
1097 assignee => %w(all only_my_events only_assigned selected),
1098 member => %w(all)
1099 }
1100
1101 tests.each do |user, expected|
1102 User::MAIL_NOTIFICATION_OPTIONS.map(&:first).each do |option|
1103 user.mail_notification = option
1104 assert_equal expected.include?(option), user.notify_about?(issue)
1105 end
1106 end
1107 end
1108
1109 def test_notify_about_issue_for_previous_assignee
1110 assignee = User.generate!(:mail_notification => 'only_assigned')
1111 new_assignee = User.generate!(:mail_notification => 'only_assigned')
1112 issue = Issue.generate!(:assigned_to => assignee)
1113
1111 1114 assert assignee.notify_about?(issue)
1112 assignee.mail_notification = 'selected'
1115 assert !new_assignee.notify_about?(issue)
1116
1117 issue.assigned_to = new_assignee
1113 1118 assert assignee.notify_about?(issue)
1119 assert new_assignee.notify_about?(issue)
1114 1120
1115 member.mail_notification = 'only_my_events'
1116 assert !member.notify_about?(issue)
1117 member.mail_notification = 'only_assigned'
1118 assert !member.notify_about?(issue)
1119 member.mail_notification = 'selected'
1120 assert !member.notify_about?(issue)
1121 issue.save!
1122 assert !assignee.notify_about?(issue)
1123 assert new_assignee.notify_about?(issue)
1121 1124 end
1122 1125
1123 1126 def test_notify_about_news
General Comments 0
You need to be logged in to leave comments. Login now