fix(KAN-14): preserve template inheritance and project data
This commit is contained in:
@@ -38,7 +38,7 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
$this->syncProjectPermissions($project, $user, ['admin']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get('/project-templates')
|
||||
@@ -79,7 +79,7 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
$this->syncProjectPermissions($project, $user, ['admin']);
|
||||
|
||||
$project->ticketTypes()->delete();
|
||||
$project->ticketStatuses()->delete();
|
||||
@@ -119,19 +119,8 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
$this->assertTrue($template->is_published);
|
||||
$this->assertNull($template->project_id);
|
||||
|
||||
$this->assertSame([
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => false,
|
||||
'show_story_points' => false,
|
||||
],
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES => [
|
||||
[
|
||||
'name' => 'Bug',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
],
|
||||
],
|
||||
], $template->configuration_snapshot);
|
||||
$this->assertSame(app(DuplicateProjectConfiguration::class)->export($project, $template->copy_areas), $template->configuration_snapshot);
|
||||
$this->assertSame($template->id, $project->fresh()->project_template_id);
|
||||
|
||||
$this->actingAs($user)
|
||||
->delete(route('project-templates.destroy', $template))
|
||||
@@ -271,6 +260,11 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
],
|
||||
])->saveQuietly();
|
||||
|
||||
app(DuplicateProjectConfiguration::class)->apply($inheritingProject, $template->configuration_snapshot, adoptExisting: true);
|
||||
$nextConfiguration = app(DuplicateProjectConfiguration::class)->normalizeConfiguration($template->configuration_snapshot);
|
||||
$nextConfiguration['project_settings'] = ['show_author' => true, 'show_story_points' => true];
|
||||
$nextConfiguration['ticket_types'][0]['name'] = 'Feature';
|
||||
|
||||
$sourceProject->forceFill([
|
||||
'show_author' => true,
|
||||
'show_story_points' => true,
|
||||
@@ -281,6 +275,7 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
$this->actingAs($user)
|
||||
->patch(route('project-templates.update', $template), [
|
||||
'name' => 'Platform Template v2',
|
||||
'configuration_snapshot' => $nextConfiguration,
|
||||
'slug' => 'should-not-change',
|
||||
'copy_areas' => [
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS,
|
||||
@@ -296,19 +291,7 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
|
||||
$this->assertSame('Platform Template v2', $template->name);
|
||||
$this->assertSame('platform-template', $template->slug);
|
||||
$this->assertSame([
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => true,
|
||||
'show_story_points' => true,
|
||||
],
|
||||
DuplicateProjectConfiguration::COPY_TICKET_TYPES => [
|
||||
[
|
||||
'name' => 'Feature',
|
||||
'position' => 1,
|
||||
'is_parent' => false,
|
||||
],
|
||||
],
|
||||
], $template->configuration_snapshot);
|
||||
$this->assertSame($nextConfiguration, $template->configuration_snapshot);
|
||||
|
||||
$this->assertTrue($inheritingProject->show_author);
|
||||
$this->assertTrue($inheritingProject->show_story_points);
|
||||
|
||||
Reference in New Issue
Block a user