Make projects depend on templates

This commit is contained in:
2026-09-08 10:25:52 +00:00
committed by Twyco
parent 40f9b473fc
commit fef82cb88f
19 changed files with 281 additions and 14 deletions
@@ -121,6 +121,13 @@ class ProjectControllerTest extends TestCase
'slug' => 'reusable-setup',
'source_project_id' => $visibleProject->id,
]);
ProjectTemplate::factory()->create([
'name' => 'Hidden Base',
'slug' => 'hidden-base',
'project_id' => $visibleProject->id,
'source_project_id' => $visibleProject->id,
'is_published' => false,
]);
$this->syncProjectPermissions($visibleProject, $user, ['view']);
$this->actingAs($user)
@@ -160,6 +167,7 @@ class ProjectControllerTest extends TestCase
$response = $this->actingAs($user)
->post(route('projects.store'), [
'creation_mode' => 'scratch',
'name' => 'Kanban Foundation',
'key' => 'core',
]);
@@ -173,6 +181,18 @@ class ProjectControllerTest extends TestCase
'key' => 'CORE',
]);
$project->refresh();
$this->assertNotNull($project->project_template_id);
$this->assertDatabaseHas('project_templates', [
'id' => $project->project_template_id,
'project_id' => $project->id,
'source_project_id' => $project->id,
'is_published' => false,
'slug' => 'core-base-template',
]);
$this->assertDatabaseHas('permission_assignments', [
'assignee_id' => $user->id,
'assignee_type' => $user->getMorphClass(),
@@ -263,8 +283,11 @@ class ProjectControllerTest extends TestCase
$response->assertRedirect(route('projects.show', $project));
$this->assertSame(false, $project->fresh()->show_author);
$this->assertSame(false, $project->fresh()->show_story_points);
$project->refresh();
$this->assertSame($template->id, $project->project_template_id);
$this->assertSame(false, $project->show_author);
$this->assertSame(false, $project->show_story_points);
$this->assertDatabaseHas('ticket_types', [
'project_id' => $project->id,
'name' => 'Bug',