GetDashboard: Return 'bad request' on misuse of 'inherited' flag

The 'inherited' flag may only be used for the default dashboard.

Instead of returning 'not found: inherited', when the 'inherited'
flag is used on a non-default dashboard, return a 'bad request'
error.

Change-Id: I46bc70d416c908336c28706a6c15cbd16c253f40
This commit is contained in:
David Pursehouse
2017-09-15 00:16:17 +09:00
parent 3d158d4ceb
commit 112cd283c8
5 changed files with 14 additions and 24 deletions

View File

@@ -22,6 +22,7 @@ import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.api.projects.DashboardInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.server.project.DashboardsCollection;
import org.eclipse.jgit.junit.TestRepository;
@@ -57,8 +58,8 @@ public class DashboardIT extends AbstractDaemonTest {
@Test
public void cannotGetDashboardWithInheritedForNonDefault() throws Exception {
DashboardInfo info = createDashboard(DashboardsCollection.DEFAULT_DASHBOARD_NAME, "test");
exception.expect(ResourceNotFoundException.class);
exception.expectMessage("inherited");
exception.expect(BadRequestException.class);
exception.expectMessage("inherited flag can only be used with default");
gApi.projects().name(project.get()).dashboard(info.id).get(true);
}