fix(teams): allow deletion with system-wide Git sources (#11500)
This commit is contained in:
parent
ac4f5af7c0
commit
53117611e4
3 changed files with 37 additions and 3 deletions
|
|
@ -283,8 +283,8 @@ public function deletionBlockers(): array
|
|||
return array_filter([
|
||||
'projects' => $this->projects()->count(),
|
||||
'servers' => $this->servers()->count(),
|
||||
'sources' => GithubApp::query()->where('team_id', $this->id)->count()
|
||||
+ GitlabApp::query()->where('team_id', $this->id)->count(),
|
||||
'sources' => GithubApp::query()->where('team_id', $this->id)->where('is_system_wide', false)->count()
|
||||
+ GitlabApp::query()->where('team_id', $this->id)->where('is_system_wide', false)->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ class="rounded-lg border border-red-300 bg-red-50 p-4 ring-1 ring-inset ring-red
|
|||
confirmationText="{{ currentTeam()->name }}"
|
||||
confirmationLabel="Enter the team name to confirm permanent deletion"
|
||||
shortConfirmationLabel="Team name" :confirmWithPassword="false"
|
||||
step2ButtonText="Permanently Delete" />
|
||||
step2ButtonText="Permanently Delete" canGate="delete"
|
||||
:canResource="$team" />
|
||||
@else
|
||||
<x-forms.button disabled tooltip="Resolve the requirements shown before deleting this team.">
|
||||
Delete team
|
||||
|
|
|
|||
|
|
@ -73,6 +73,39 @@
|
|||
->and(PrivateKey::find($privateKey->id))->toBeNull();
|
||||
});
|
||||
|
||||
test('system-wide git sources do not block team deletion', function () {
|
||||
Team::forceCreate([
|
||||
'id' => 0,
|
||||
'name' => 'Root Team',
|
||||
'personal_team' => false,
|
||||
]);
|
||||
|
||||
$githubApp = GithubApp::forceCreate([
|
||||
'name' => 'System-wide GitHub source',
|
||||
'team_id' => $this->teamToDelete->id,
|
||||
'api_url' => 'https://api.github.com',
|
||||
'html_url' => 'https://github.com',
|
||||
'is_public' => false,
|
||||
'is_system_wide' => true,
|
||||
]);
|
||||
$gitlabApp = GitlabApp::forceCreate([
|
||||
'name' => 'System-wide GitLab source',
|
||||
'team_id' => $this->teamToDelete->id,
|
||||
'api_url' => 'https://gitlab.com/api/v4',
|
||||
'html_url' => 'https://gitlab.com',
|
||||
'is_public' => false,
|
||||
'is_system_wide' => true,
|
||||
]);
|
||||
|
||||
expect($this->teamToDelete->isEmpty())->toBeTrue();
|
||||
|
||||
app(DeleteTeam::class)->handle($this->teamToDelete, $this->owner);
|
||||
|
||||
expect(Team::find($this->teamToDelete->id))->toBeNull()
|
||||
->and($githubApp->refresh()->team_id)->toBe(0)
|
||||
->and($gitlabApp->refresh()->team_id)->toBe(0);
|
||||
});
|
||||
|
||||
test('the danger zone names and links blocking resource types', function () {
|
||||
Project::factory()->count(2)->create(['team_id' => $this->teamToDelete->id]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue