Make projects depend on templates
This commit is contained in:
@@ -29,6 +29,13 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
'slug' => 'foundation-template',
|
||||
'source_project_id' => $project->id,
|
||||
]);
|
||||
ProjectTemplate::factory()->create([
|
||||
'name' => 'Hidden Base Template',
|
||||
'slug' => 'hidden-base-template',
|
||||
'project_id' => $project->id,
|
||||
'source_project_id' => $project->id,
|
||||
'is_published' => false,
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
$this->syncProjectPermissions($project, $user, ['view']);
|
||||
@@ -40,7 +47,8 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
->component('project-templates/Index')
|
||||
->has('templates', 1)
|
||||
->where('templates.0.id', $template->id)
|
||||
->where('templates.0.slug', 'foundation-template'));
|
||||
->where('templates.0.slug', 'foundation-template')
|
||||
->where('templates.0.is_published', true));
|
||||
|
||||
$this->actingAs($user)
|
||||
->get(route('projects.templates.create', $project))
|
||||
@@ -99,6 +107,9 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
|
||||
$template = ProjectTemplate::query()->where('slug', 'core-reusable')->firstOrFail();
|
||||
|
||||
$this->assertTrue($template->is_published);
|
||||
$this->assertNull($template->project_id);
|
||||
|
||||
$this->assertSame([
|
||||
DuplicateProjectConfiguration::COPY_PROJECT_SETTINGS => [
|
||||
'show_author' => false,
|
||||
@@ -121,4 +132,21 @@ class ProjectTemplateControllerTest extends TestCase
|
||||
'id' => $template->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_hidden_base_templates_cannot_be_deleted_from_the_management_flow(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create();
|
||||
$template = ProjectTemplate::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'source_project_id' => $project->id,
|
||||
'is_published' => false,
|
||||
]);
|
||||
|
||||
$this->syncGlobalPermissions($user, ['project:create']);
|
||||
|
||||
$this->actingAs($user)
|
||||
->delete(route('project-templates.destroy', $template))
|
||||
->assertNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user