Merge "Fall back to addByEmail for inactive CCs"
This commit is contained in:
@@ -65,9 +65,11 @@ import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
import com.google.gerrit.extensions.client.Comment.Range;
|
||||
import com.google.gerrit.extensions.client.InheritableBoolean;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.client.Side;
|
||||
@@ -1094,6 +1096,31 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
assertThat(r.reviewers).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addReviewerThatIsInactiveEmailFallback() throws Exception {
|
||||
assume().that(notesMigration.enabled()).isTrue();
|
||||
|
||||
ConfigInput conf = new ConfigInput();
|
||||
conf.enableReviewerByEmail = InheritableBoolean.TRUE;
|
||||
gApi.projects().name(project.get()).config(conf);
|
||||
|
||||
PushOneCommit.Result result = createChange();
|
||||
|
||||
String username = "user@domain.com";
|
||||
gApi.accounts().create(username).setActive(false);
|
||||
|
||||
AddReviewerInput in = new AddReviewerInput();
|
||||
in.reviewer = username;
|
||||
in.state = ReviewerState.CC;
|
||||
AddReviewerResult r = gApi.changes().id(result.getChangeId()).addReviewer(in);
|
||||
|
||||
assertThat(r.input).isEqualTo(username);
|
||||
assertThat(r.error).isNull();
|
||||
// When adding by email, the reviewers field is also empty because we can't
|
||||
// render a ReviewerInfo object for a non-account.
|
||||
assertThat(r.reviewers).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addReviewer() throws Exception {
|
||||
TestTimeUtil.resetWithClockStep(1, SECONDS);
|
||||
|
||||
@@ -240,6 +240,9 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
reviewer, rsrc, ImmutableSet.of(member.getId()), null, state, notify, accountsToNotify);
|
||||
}
|
||||
if (!member.isActive()) {
|
||||
if (allowByEmail && state == CC) {
|
||||
return null;
|
||||
}
|
||||
return fail(reviewer, MessageFormat.format(ChangeMessages.get().reviewerInactive, reviewer));
|
||||
}
|
||||
return fail(
|
||||
|
||||
Reference in New Issue
Block a user