(Re)enable voting buttons for merged changes

Change I025b64 had to disable the voting buttons on merged changes to
fix replying on merged changes. However having the voting buttons
enabled for merged changes is desired after change Ie337b5 added
backend support for voting on merged changes.

To reenable them ChangeJson must set the 'permitted_labels' field for
merged changes and make sure that each permitted label is contained in
the 'labels' field.

For changes which were auto-merged by Gerrit due to direct push of the
commit there may be no approvals on the change although the change
status is MERGED. This means for populating the 'labels' field for
merged changes we cannot rely on the approvals.

Instead of relying on the approvals set the 'labels' field for merged
changes based on the submit records. This is the same way how the
labels for open changes and permitted labels are computed.

The voting range returned by 'permitted_labels' for merged changes is
not always correct yet, since it returns the voting range that is
allowed to the user, but it doesn't respect the fact that downgrading
of votes is not possible for merged changes. This is a minor issue,
since the user gets a proper error message if downgrading of a vote on
a merged change is attempted. Hence it can be fixed in a follow-up
change.

Change-Id: Iba501e00bee77be3bd0ced72f88fd04ba0accaed
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-10-26 11:05:56 +02:00
parent f543bd9bdf
commit 533e3ad84f
2 changed files with 29 additions and 15 deletions

View File

@@ -2123,7 +2123,7 @@ public class ChangeIT extends AbstractDaemonTest {
.get();
assertThat(change.status).isEqualTo(ChangeStatus.MERGED);
assertThat(change.labels.keySet()).containsExactly("Code-Review");
assertThat(change.permittedLabels).isEmpty();
assertThat(change.permittedLabels.keySet()).containsExactly("Code-Review");
}
@Test
@@ -2138,8 +2138,8 @@ public class ChangeIT extends AbstractDaemonTest {
.id(r.getChangeId())
.get();
assertThat(change.status).isEqualTo(ChangeStatus.MERGED);
assertThat(change.labels).isEmpty();
assertThat(change.permittedLabels).isEmpty();
assertThat(change.labels.keySet()).containsExactly("Code-Review");
assertThat(change.permittedLabels.keySet()).containsExactly("Code-Review");
}
@Test