Merge pull request 'KAN-6 Project rely on project templates' (#88) from koda/kan-6-project-rely-on-project-templates into epic/kan-3
Reviewed-on: OpenSource/KanbanGit#88
This commit was merged in pull request #88.
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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