Notedb: Add user as reviewer when posting a review with new approvals

The PostReview REST endpoint allows users to put approvals onto the
change. If a new approval was added the user was not recorded as
reviewer in notedb. Hence the ChangeInfo.reviewed field was not set
when notedb was enabled.

This fixes the ChangeIT#checkReviewedFlagBeforeAndAfterReview() test
that failed when notedb was enabled.

Change-Id: Ia57dc1ce9701f954a0d63037d53000b4a877f4f0
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin 2015-11-10 16:15:52 -08:00
parent 6f02e7e242
commit 3d09b6e474

View File

@ -64,6 +64,7 @@ import com.google.gerrit.server.git.BatchUpdate.ChangeContext;
import com.google.gerrit.server.git.BatchUpdate.Context;
import com.google.gerrit.server.git.UpdateException;
import com.google.gerrit.server.notedb.ChangeUpdate;
import com.google.gerrit.server.notedb.ReviewerState;
import com.google.gerrit.server.patch.PatchListCache;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.query.change.ChangeData;
@ -548,6 +549,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
ups.add(c);
addLabelDelta(normName, c.getValue());
categories.put(normName, c.getValue());
update.putReviewer(user.getAccountId(), ReviewerState.REVIEWER);
update.putApproval(ent.getKey(), ent.getValue());
}
}