fix: make project template inheritance granular and safe
CI/CD / test_and_check_app (push) Failing after 3m8s
CI/CD / Publish immutable image (push) Skipped
CI/CD / test_and_check_app (pull_request) Failing after 3m8s
CI/CD / Publish immutable image (pull_request) Skipped

This commit is contained in:
Nico Schröder
2026-09-08 10:25:52 +00:00
committed by Twyco
parent fed6a282a4
commit 9895fc36db
50 changed files with 1504 additions and 624 deletions
@@ -72,7 +72,7 @@ class ProjectTemplateBaselineMigrationTest extends TestCase
$this->assertSame('lgcy-base-template', $template->slug);
}
public function test_metadata_migration_moves_existing_configuration_to_the_project_template_and_preserves_snapshot(): void
public function test_metadata_migration_moves_existing_configuration_and_preserves_published_template_links(): void
{
Artisan::call('migrate:fresh', [
'--path' => [
@@ -131,6 +131,42 @@ class ProjectTemplateBaselineMigrationTest extends TestCase
'updated_at' => now(),
]);
DB::table('projects')->insert([
'name' => 'Linked Project',
'key' => 'LINK',
'show_author' => 1,
'show_story_points' => 0,
'project_template_id' => null,
'created_at' => now(),
'updated_at' => now(),
]);
$linkedProjectId = (int) DB::table('projects')->where('key', 'LINK')->value('id');
$publishedSnapshot = [
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
'show_author' => false,
'show_story_points' => true,
],
];
$publishedTemplateId = DB::table('project_templates')->insertGetId([
'project_id' => null,
'source_project_id' => $projectId,
'name' => 'Published Template',
'slug' => 'published-template',
'is_published' => true,
'copy_areas' => json_encode(
[DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS],
JSON_THROW_ON_ERROR,
),
'configuration_snapshot' => json_encode($publishedSnapshot, JSON_THROW_ON_ERROR),
'created_at' => now(),
'updated_at' => now(),
]);
DB::table('projects')->where('id', $linkedProjectId)->update([
'project_template_id' => $publishedTemplateId,
]);
Artisan::call('migrate', [
'--path' => 'database/migrations/2026_06_05_161500_move_project_metadata_to_project_templates.php',
]);
@@ -142,5 +178,18 @@ class ProjectTemplateBaselineMigrationTest extends TestCase
$this->assertSame($project->project_template_id, $ticketType->project_template_id);
$this->assertSame(['Bug'], array_column($snapshot[DuplicateProjectConfiguration::COPY_TICKET_TYPES], 'name'));
$this->assertSame(
$publishedTemplateId,
DB::table('projects')->where('id', $linkedProjectId)->value('project_template_id'),
);
$this->assertSame(
$publishedSnapshot,
json_decode(
(string) DB::table('project_templates')->where('id', $publishedTemplateId)->value('configuration_snapshot'),
true,
512,
JSON_THROW_ON_ERROR,
),
);
}
}