diff --git a/src/lib/Hydra/Controller/Project.pm b/src/lib/Hydra/Controller/Project.pm index c38ff6ad..c7e64544 100644 --- a/src/lib/Hydra/Controller/Project.pm +++ b/src/lib/Hydra/Controller/Project.pm @@ -78,8 +78,8 @@ sub project_DELETE { requireProjectOwner($c, $c->stash->{project}); $c->model('DB')->schema->txn_do(sub { - $c->stash->{project}->jobsets->delete; $c->stash->{project}->builds->delete; + $c->stash->{project}->jobsets->delete; $c->stash->{project}->delete; }); diff --git a/t/Hydra/Controller/Project/delete.t b/t/Hydra/Controller/Project/delete.t index 203fe106..f162a0f6 100644 --- a/t/Hydra/Controller/Project/delete.t +++ b/t/Hydra/Controller/Project/delete.t @@ -55,4 +55,21 @@ subtest "Deleting a simple project" => sub { ); }; -done_testing; \ No newline at end of file +subtest "Deleting a project with metrics" => sub { + my $builds = $ctx->makeAndEvaluateJobset( + expression => "runcommand.nix", + build => 1 + ); + my $project = $builds->{"metrics"}->project; + + my $responseAuthed = request(DELETE "/project/${\$project->name}", + Cookie => $cookie, + Accept => "application/json" + ); + is($responseAuthed->code, 200, "Deleting a project with auth returns a 200"); + + my $response = request(GET "/project/${\$project->name}"); + is($response->code, 404, "Then getting the project returns a 404"); +}; + +done_testing;