@@ -1084,77 +1084,40 class UserTest < ActiveSupport::TestCase | |||
|
1084 | 1084 | assert_equal true, @anonymous.allowed_to_globally?(:view_issues) |
|
1085 | 1085 | end |
|
1086 | 1086 | |
|
1087 | context "User#notify_about?" do | |
|
1088 | context "Issues" do | |
|
1089 | setup do | |
|
1090 | @project = Project.find(1) | |
|
1091 |
|
|
|
1092 | @assignee = User.generate! | |
|
1093 |
|
|
|
1094 | end | |
|
1095 | ||
|
1096 | should "be true for a user with :all" do | |
|
1097 |
|
|
|
1098 |
|
|
|
1099 | end | |
|
1100 | ||
|
1101 | should "be false for a user with :none" do | |
|
1102 | @author.update_attribute(:mail_notification, 'none') | |
|
1103 | assert ! @author.notify_about?(@issue) | |
|
1104 | end | |
|
1105 | ||
|
1106 | should "be false for a user with :only_my_events and isn't an author, creator, or assignee" do | |
|
1107 | @user = User.generate!(:mail_notification => 'only_my_events') | |
|
1108 | Member.create!(:user => @user, :project => @project, :role_ids => [1]) | |
|
1109 |
|
|
|
1110 | end | |
|
1111 | ||
|
1112 | should "be true for a user with :only_my_events and is the author" do | |
|
1113 | @author.update_attribute(:mail_notification, 'only_my_events') | |
|
1114 | assert @author.notify_about?(@issue) | |
|
1115 | end | |
|
1116 | ||
|
1117 | should "be true for a user with :only_my_events and is the assignee" do | |
|
1118 | @assignee.update_attribute(:mail_notification, 'only_my_events') | |
|
1119 | assert @assignee.notify_about?(@issue) | |
|
1120 | end | |
|
1121 | ||
|
1122 | should "be true for a user with :only_assigned and is the assignee" do | |
|
1123 | @assignee.update_attribute(:mail_notification, 'only_assigned') | |
|
1124 | assert @assignee.notify_about?(@issue) | |
|
1125 | end | |
|
1126 | ||
|
1127 | should "be false for a user with :only_assigned and is not the assignee" do | |
|
1128 | @author.update_attribute(:mail_notification, 'only_assigned') | |
|
1129 | assert ! @author.notify_about?(@issue) | |
|
1130 | end | |
|
1131 | ||
|
1132 | should "be true for a user with :only_owner and is the author" do | |
|
1133 | @author.update_attribute(:mail_notification, 'only_owner') | |
|
1134 | assert @author.notify_about?(@issue) | |
|
1135 | end | |
|
1136 | ||
|
1137 | should "be false for a user with :only_owner and is not the author" do | |
|
1138 | @assignee.update_attribute(:mail_notification, 'only_owner') | |
|
1139 | assert ! @assignee.notify_about?(@issue) | |
|
1140 | end | |
|
1141 | ||
|
1142 | should "be true for a user with :selected and is the author" do | |
|
1143 | @author.update_attribute(:mail_notification, 'selected') | |
|
1144 | assert @author.notify_about?(@issue) | |
|
1145 | end | |
|
1146 | ||
|
1147 | should "be true for a user with :selected and is the assignee" do | |
|
1148 | @assignee.update_attribute(:mail_notification, 'selected') | |
|
1149 | assert @assignee.notify_about?(@issue) | |
|
1150 | end | |
|
1151 | ||
|
1152 | should "be false for a user with :selected and is not the author or assignee" do | |
|
1153 | @user = User.generate!(:mail_notification => 'selected') | |
|
1154 | Member.create!(:user => @user, :project => @project, :role_ids => [1]) | |
|
1155 | assert ! @user.notify_about?(@issue) | |
|
1156 | end | |
|
1157 | end | |
|
1087 | def test_notify_about_for_issue | |
|
1088 | project = Project.find(1) | |
|
1089 | author = User.generate! | |
|
1090 | assignee = User.generate! | |
|
1091 | member = User.generate! | |
|
1092 | Member.create!(:user => member, :project => project, :role_ids => [1]) | |
|
1093 | issue = Issue.generate!(:project => project, :assigned_to => assignee, :author => author) | |
|
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' | |
|
1111 | assert assignee.notify_about?(issue) | |
|
1112 | assignee.mail_notification = 'selected' | |
|
1113 | assert assignee.notify_about?(issue) | |
|
1114 | ||
|
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) | |
|
1158 | 1121 | end |
|
1159 | 1122 | |
|
1160 | 1123 | def test_notify_about_news |
General Comments 0
You need to be logged in to leave comments.
Login now