Merge "Fix setting draft status of created changes"
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.rest.change;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.RestResponse;
|
import com.google.gerrit.acceptance.RestResponse;
|
||||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||||
@@ -84,5 +85,15 @@ public class CreateChangeIT extends AbstractDaemonTest {
|
|||||||
assertThat(out.subject).isEqualTo(in.subject);
|
assertThat(out.subject).isEqualTo(in.subject);
|
||||||
assertThat(out.topic).isEqualTo(in.topic);
|
assertThat(out.topic).isEqualTo(in.topic);
|
||||||
assertThat(out.status).isEqualTo(in.status);
|
assertThat(out.status).isEqualTo(in.status);
|
||||||
|
assertThat(out.revisions).hasSize(1);
|
||||||
|
Boolean draft = Iterables.getOnlyElement(out.revisions.values()).draft;
|
||||||
|
assertThat(booleanToDraftStatus(draft)).isEqualTo(in.status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChangeStatus booleanToDraftStatus(Boolean draft) {
|
||||||
|
if (draft == null) {
|
||||||
|
return ChangeStatus.NEW;
|
||||||
|
}
|
||||||
|
return draft ? ChangeStatus.DRAFT : ChangeStatus.NEW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,8 +203,7 @@ public class CreateChange implements
|
|||||||
updateRef(git, rw, c, change, ins.getPatchSet());
|
updateRef(git, rw, c, change, ins.getPatchSet());
|
||||||
|
|
||||||
change.setTopic(input.topic);
|
change.setTopic(input.topic);
|
||||||
change.setStatus(input.status != null
|
ins.setDraft(input.status != null && input.status == ChangeStatus.DRAFT);
|
||||||
? Change.Status.forChangeStatus(input.status) : Change.Status.NEW);
|
|
||||||
ins.insert();
|
ins.insert();
|
||||||
|
|
||||||
return Response.created(json.format(change.getId()));
|
return Response.created(json.format(change.getId()));
|
||||||
|
|||||||
Reference in New Issue
Block a user