mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Removed most usages of restricted entitiy property
This commit is contained in:
@@ -50,9 +50,7 @@ class AttachmentsApiTest extends TestCase
|
||||
],
|
||||
]]);
|
||||
|
||||
$page->restricted = true;
|
||||
$page->save();
|
||||
$this->entities->regenPermissions($page);
|
||||
$this->entities->setPermissions($page, [], []);
|
||||
|
||||
$resp = $this->getJson($this->baseEndpoint . '?count=1&sort=+id');
|
||||
$resp->assertJsonMissing(['data' => [
|
||||
|
@@ -19,7 +19,7 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
$shelf = $this->entities->shelf();
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
|
||||
$this->assertFalse(boolval($child->hasPermissions()), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->entities->setPermissions($shelf, ['view', 'update'], [$editorRole]);
|
||||
@@ -28,7 +28,7 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
]);
|
||||
$child = $shelf->books()->first();
|
||||
|
||||
$this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
|
||||
$this->assertTrue(boolval($child->hasPermissions()), 'Child book should now be restricted');
|
||||
$this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
|
||||
@@ -40,7 +40,7 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
Bookshelf::query()->where('id', '!=', $shelf->id)->delete();
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
|
||||
$this->assertFalse(boolval($child->hasPermissions()), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->entities->setPermissions($shelf, ['view', 'update'], [$editorRole]);
|
||||
@@ -48,7 +48,7 @@ class CopyShelfPermissionsCommandTest extends TestCase
|
||||
->expectsQuestion('Permission settings for all shelves will be cascaded. Books assigned to multiple shelves will receive only the permissions of it\'s last processed shelf. Are you sure you want to proceed?', 'y');
|
||||
$child = $shelf->books()->first();
|
||||
|
||||
$this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
|
||||
$this->assertTrue(boolval($child->hasPermissions()), 'Child book should now be restricted');
|
||||
$this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
|
||||
|
@@ -295,7 +295,7 @@ class BookShelfTest extends TestCase
|
||||
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
$this->assertFalse(boolval($child->restricted), 'Child book should not be restricted by default');
|
||||
$this->assertFalse(boolval($child->hasPermissions()), 'Child book should not be restricted by default');
|
||||
$this->assertTrue($child->permissions()->count() === 0, 'Child book should have no permissions by default');
|
||||
|
||||
$this->entities->setPermissions($shelf, ['view', 'update'], [$editorRole]);
|
||||
@@ -303,7 +303,7 @@ class BookShelfTest extends TestCase
|
||||
$child = $shelf->books()->first();
|
||||
|
||||
$resp->assertRedirect($shelf->getUrl());
|
||||
$this->assertTrue(boolval($child->restricted), 'Child book should now be restricted');
|
||||
$this->assertTrue(boolval($child->hasPermissions()), 'Child book should now be restricted');
|
||||
$this->assertTrue($child->permissions()->count() === 2, 'Child book should have copied permissions');
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'view', 'role_id' => $editorRole->id]);
|
||||
$this->assertDatabaseHas('entity_permissions', ['restrictable_id' => $child->id, 'action' => 'update', 'role_id' => $editorRole->id]);
|
||||
|
@@ -304,9 +304,7 @@ class BookTest extends TestCase
|
||||
// Hide child content
|
||||
/** @var BookChild $page */
|
||||
foreach ($book->getDirectChildren() as $child) {
|
||||
$child->restricted = true;
|
||||
$child->save();
|
||||
$this->entities->regenPermissions($child);
|
||||
$this->entities->setPermissions($child, [], []);
|
||||
}
|
||||
|
||||
$this->asEditor()->post($book->getUrl('/copy'), ['name' => 'My copy book']);
|
||||
|
@@ -101,9 +101,7 @@ class ChapterTest extends TestCase
|
||||
// Hide pages to all non-admin roles
|
||||
/** @var Page $page */
|
||||
foreach ($chapter->pages as $page) {
|
||||
$page->restricted = true;
|
||||
$page->save();
|
||||
$this->entities->regenPermissions($page);
|
||||
$this->entities->setPermissions($page, [], []);
|
||||
}
|
||||
|
||||
$this->asEditor()->post($chapter->getUrl('/copy'), [
|
||||
|
@@ -172,8 +172,7 @@ class EntitySearchTest extends TestCase
|
||||
|
||||
// Restricted filter
|
||||
$this->get('/search?term=' . urlencode('danzorbhsing {is_restricted}'))->assertDontSee($page->name);
|
||||
$page->restricted = true;
|
||||
$page->save();
|
||||
$this->entities->setPermissions($page, [], []);
|
||||
$this->get('/search?term=' . urlencode('danzorbhsing {is_restricted}'))->assertSee($page->name);
|
||||
|
||||
// Date filters
|
||||
|
@@ -75,9 +75,7 @@ class TagTest extends TestCase
|
||||
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
|
||||
|
||||
// Set restricted permission the page
|
||||
$page->restricted = true;
|
||||
$page->save();
|
||||
$page->rebuildPermissions();
|
||||
$this->entities->setPermissions($page, [], []);
|
||||
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
|
||||
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson([]);
|
||||
@@ -180,8 +178,7 @@ class TagTest extends TestCase
|
||||
$resp = $this->get('/tags?name=SuperCategory');
|
||||
$resp->assertSee('GreatTestContent');
|
||||
|
||||
$page->restricted = true;
|
||||
$this->entities->regenPermissions($page);
|
||||
$this->entities->setPermissions($page, [], []);
|
||||
|
||||
$resp = $this->asEditor()->get('/tags');
|
||||
$resp->assertDontSee('SuperCategory');
|
||||
|
@@ -204,7 +204,6 @@ class EntityProvider
|
||||
*/
|
||||
public function setPermissions(Entity $entity, array $actions = [], array $roles = []): void
|
||||
{
|
||||
$entity->restricted = true;
|
||||
$entity->permissions()->delete();
|
||||
|
||||
$permissions = [];
|
||||
@@ -217,7 +216,6 @@ class EntityProvider
|
||||
}
|
||||
|
||||
$entity->permissions()->createMany($permissions);
|
||||
$entity->save();
|
||||
$entity->load('permissions');
|
||||
$this->regenPermissions($entity);
|
||||
}
|
||||
|
@@ -376,7 +376,6 @@ class EntityPermissionsTest extends TestCase
|
||||
->assertSee($title);
|
||||
|
||||
$this->put($modelInstance->getUrl('/permissions'), [
|
||||
'restricted' => 'true',
|
||||
'restrictions' => [
|
||||
$roleId => [
|
||||
$permission => 'true',
|
||||
|
@@ -253,11 +253,7 @@ class AttachmentTest extends TestCase
|
||||
$this->uploadFile($fileName, $page->id);
|
||||
$attachment = Attachment::orderBy('id', 'desc')->take(1)->first();
|
||||
|
||||
$page->restricted = true;
|
||||
$page->permissions()->delete();
|
||||
$page->save();
|
||||
$page->rebuildPermissions();
|
||||
$page->load('jointPermissions');
|
||||
$this->entities->setPermissions($page, [], []);
|
||||
|
||||
$this->actingAs($viewer);
|
||||
$attachmentGet = $this->get($attachment->getUrl());
|
||||
|
Reference in New Issue
Block a user