Skip to content

Commit

Permalink
[4.x] Use 'configure' permission for configuring navs (#9961)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonerd authored Apr 26, 2024
1 parent 99c6cbe commit 94666c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function edit($nav)
{
$nav = Nav::find($nav);

$this->authorize('edit', $nav, __('You are not authorized to configure navs.'));
$this->authorize('configure', $nav, __('You are not authorized to configure navs.'));

$values = [
'title' => $nav->title(),
Expand Down
5 changes: 5 additions & 0 deletions src/Policies/NavPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public function store($user)
// handled by before()
}

public function configure($user)
{
// handled by before()
}

public function view($user, $nav)
{
$user = User::fromUser($user);
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/Navigation/EditNavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ class EditNavigationTest extends TestCase
use PreventSavingStacheItemsToDisk;

/** @test */
public function it_shows_the_edit_form_if_user_has_edit_permission()
public function it_shows_the_edit_form_if_user_has_configure_permission()
{
$nav = $this->createNav('foo');
Nav::shouldReceive('all')->andReturn(collect([$nav]));
Nav::shouldReceive('find')->andReturn($nav);

$this->setTestRoles(['test' => ['access cp', 'edit foo nav']]);
$this->setTestRoles(['test' => ['access cp', 'configure navs']]);
$user = Facades\User::make()->assignRole('test')->save();

$response = $this
Expand All @@ -32,7 +32,7 @@ public function it_shows_the_edit_form_if_user_has_edit_permission()
}

/** @test */
public function it_denies_access_if_user_doesnt_have_edit_permission()
public function it_denies_access_if_user_doesnt_have_configure_permission()
{
$nav = $this->createNav('foo');
Nav::shouldReceive('all')->andReturn(collect([$nav]));
Expand Down

0 comments on commit 94666c2

Please sign in to comment.