Seiten: Unterseiten anlegen als eigenes Recht (0.25.2)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m4s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m58s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m38s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m28s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m49s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m51s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 5m4s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m58s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 5m0s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m38s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m28s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m54s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m49s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m51s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
84a9815150
commit
fbee65f948
8 changed files with 85 additions and 8 deletions
|
|
@ -47,11 +47,15 @@ class PagesTest extends TestCase
|
|||
return $page->fresh();
|
||||
}
|
||||
|
||||
private function mavRole(Page $page, bool $publish = true): Role
|
||||
private function mavRole(Page $page, bool $publish = true, bool $create = false): Role
|
||||
{
|
||||
$role = Role::query()->create(['name' => 'MAV']);
|
||||
$role->grants()->create(['ability' => 'pages.edit', 'resource_type' => 'page', 'resource_id' => $page->id, 'include_children' => true]);
|
||||
|
||||
if ($create) {
|
||||
$role->grants()->create(['ability' => 'pages.create', 'resource_type' => 'page', 'resource_id' => $page->id, 'include_children' => true]);
|
||||
}
|
||||
|
||||
if ($publish) {
|
||||
$role->grants()->create(['ability' => 'pages.publish', 'resource_type' => 'page', 'resource_id' => $page->id, 'include_children' => true]);
|
||||
}
|
||||
|
|
@ -108,7 +112,7 @@ class PagesTest extends TestCase
|
|||
{
|
||||
$mavPage = $this->publishedPage('MAV');
|
||||
$other = $this->publishedPage('Geschäftsführung');
|
||||
$mav = User::factory()->withRoles([$this->mavRole($mavPage)])->create();
|
||||
$mav = User::factory()->withRoles([$this->mavRole($mavPage, create: true)])->create();
|
||||
|
||||
$this->actingAs($mav)->post('/redaktion/seiten', ['title' => 'Wahlen', 'parent_id' => $mavPage->id])->assertRedirect();
|
||||
$child = Page::query()->where('title', 'Wahlen')->sole();
|
||||
|
|
@ -319,4 +323,26 @@ class PagesTest extends TestCase
|
|||
|
||||
$this->assertTrue($user->fresh()->can('update', $child));
|
||||
}
|
||||
|
||||
public function test_creating_subpages_is_a_separate_optional_right(): void
|
||||
{
|
||||
$mavPage = $this->publishedPage('MAV');
|
||||
$role = $this->mavRole($mavPage);
|
||||
$member = User::factory()->withRoles([$role])->create();
|
||||
|
||||
// Nur bearbeiten/veröffentlichen: keine Unterseiten
|
||||
$this->actingAs($member)->post('/redaktion/seiten', ['title' => 'Wahlen', 'parent_id' => $mavPage->id])->assertForbidden();
|
||||
$this->get('/redaktion/seiten/'.$mavPage->id)->assertInertia(fn (Assert $p) => $p->where('page.can.create_child', false));
|
||||
|
||||
$role->grants()->create(['ability' => 'pages.create', 'resource_type' => 'page', 'resource_id' => $mavPage->id, 'include_children' => true]);
|
||||
Permissions::flush();
|
||||
|
||||
$this->post('/redaktion/seiten', ['title' => 'Wahlen', 'parent_id' => $mavPage->id])->assertRedirect();
|
||||
$child = Page::query()->where('title', 'Wahlen')->sole();
|
||||
$this->assertSame($mavPage->id, $child->parent_id);
|
||||
$this->assertTrue($member->fresh()->can('update', $child));
|
||||
|
||||
// Oberste Ebene bleibt „Seiten verwalten“ vorbehalten
|
||||
$this->post('/redaktion/seiten', ['title' => 'Eigenes'])->assertForbidden();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue