Respect notify option when pushing new changes
Users can add a notify option to the push spec to control to whom email notifications should be sent, but the notify option had no effect when a new change was pushed. Change-Id: Ie802526ef486f3a36da1b4ac6ec4ada07026efa1 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -31,6 +31,7 @@ import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput.NotifyHandling;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.EditInfo;
|
||||
@@ -42,6 +43,7 @@ import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
import com.google.gerrit.server.project.Util;
|
||||
import com.google.gerrit.testutil.TestTimeUtil;
|
||||
import com.google.gerrit.testutil.FakeEmailSender.Message;
|
||||
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.junit.AfterClass;
|
||||
@@ -126,6 +128,40 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
|
||||
r.assertChange(Change.Status.NEW, topic);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPushForMasterWithNotify() throws Exception {
|
||||
TestAccount user2 = accounts.user2();
|
||||
String pushSpec = "refs/for/master"
|
||||
+ "%reviewer=" + user.email
|
||||
+ ",cc=" + user2.email;
|
||||
|
||||
sender.clear();
|
||||
PushOneCommit.Result r =
|
||||
pushTo(pushSpec + ",notify=" + NotifyHandling.NONE);
|
||||
r.assertOkStatus();
|
||||
assertThat(sender.getMessages()).hasSize(0);
|
||||
|
||||
sender.clear();
|
||||
r = pushTo(pushSpec + ",notify=" + NotifyHandling.OWNER);
|
||||
r.assertOkStatus();
|
||||
// no email notification about own changes
|
||||
assertThat(sender.getMessages()).hasSize(0);
|
||||
|
||||
sender.clear();
|
||||
r = pushTo(pushSpec + ",notify=" + NotifyHandling.OWNER_REVIEWERS);
|
||||
r.assertOkStatus();
|
||||
assertThat(sender.getMessages()).hasSize(1);
|
||||
Message m = sender.getMessages().get(0);
|
||||
assertThat(m.rcpt()).containsExactly(user.emailAddress);
|
||||
|
||||
sender.clear();
|
||||
r = pushTo(pushSpec + ",notify=" + NotifyHandling.ALL);
|
||||
r.assertOkStatus();
|
||||
assertThat(sender.getMessages()).hasSize(1);
|
||||
m = sender.getMessages().get(0);
|
||||
assertThat(m.rcpt()).containsExactly(user.emailAddress, user2.emailAddress);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPushForMasterWithCc() throws Exception {
|
||||
// cc one user
|
||||
|
Reference in New Issue
Block a user