mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-08-09 10:22:51 +03:00
Copied over work from user_permissions branch
Only that relevant to the additional testing work.
This commit is contained in:
@@ -14,7 +14,7 @@ class RecycleBinTest extends TestCase
|
||||
public function test_recycle_bin_routes_permissions()
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
$editor = $this->getEditor();
|
||||
$editor = $this->users->editor();
|
||||
$this->actingAs($editor)->delete($page->getUrl());
|
||||
$deletion = Deletion::query()->firstOrFail();
|
||||
|
||||
@@ -33,7 +33,7 @@ class RecycleBinTest extends TestCase
|
||||
$this->assertPermissionError($resp);
|
||||
}
|
||||
|
||||
$this->giveUserPermissions($editor, ['restrictions-manage-all']);
|
||||
$this->permissions->grantUserRolePermissions($editor, ['restrictions-manage-all']);
|
||||
|
||||
foreach ($routes as $route) {
|
||||
[$method, $url] = explode(':', $route);
|
||||
@@ -41,7 +41,7 @@ class RecycleBinTest extends TestCase
|
||||
$this->assertPermissionError($resp);
|
||||
}
|
||||
|
||||
$this->giveUserPermissions($editor, ['settings-manage']);
|
||||
$this->permissions->grantUserRolePermissions($editor, ['settings-manage']);
|
||||
|
||||
foreach ($routes as $route) {
|
||||
DB::beginTransaction();
|
||||
@@ -56,7 +56,7 @@ class RecycleBinTest extends TestCase
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
$book = Book::query()->whereHas('pages')->whereHas('chapters')->withCount(['pages', 'chapters'])->first();
|
||||
$editor = $this->getEditor();
|
||||
$editor = $this->users->editor();
|
||||
$this->actingAs($editor)->delete($page->getUrl());
|
||||
$this->actingAs($editor)->delete($book->getUrl());
|
||||
|
||||
@@ -73,7 +73,7 @@ class RecycleBinTest extends TestCase
|
||||
{
|
||||
$page = $this->entities->page();
|
||||
$book = Book::query()->where('id', '!=', $page->book_id)->whereHas('pages')->whereHas('chapters')->with(['pages', 'chapters'])->firstOrFail();
|
||||
$editor = $this->getEditor();
|
||||
$editor = $this->users->editor();
|
||||
$this->actingAs($editor)->delete($page->getUrl());
|
||||
$this->actingAs($editor)->delete($book->getUrl());
|
||||
|
||||
|
@@ -32,11 +32,11 @@ class RegenerateReferencesTest extends TestCase
|
||||
|
||||
public function test_settings_manage_permission_required()
|
||||
{
|
||||
$editor = $this->getEditor();
|
||||
$editor = $this->users->editor();
|
||||
$resp = $this->actingAs($editor)->post('/settings/maintenance/regenerate-references');
|
||||
$this->assertPermissionError($resp);
|
||||
|
||||
$this->giveUserPermissions($editor, ['settings-manage']);
|
||||
$this->permissions->grantUserRolePermissions($editor, ['settings-manage']);
|
||||
|
||||
$resp = $this->actingAs($editor)->post('/settings/maintenance/regenerate-references');
|
||||
$this->assertNotPermissionError($resp);
|
||||
|
@@ -20,7 +20,7 @@ class TestEmailTest extends TestCase
|
||||
public function test_send_test_email_endpoint_sends_email_and_redirects_user_and_shows_notification()
|
||||
{
|
||||
Notification::fake();
|
||||
$admin = $this->getAdmin();
|
||||
$admin = $this->users->admin();
|
||||
|
||||
$sendReq = $this->actingAs($admin)->post('/settings/maintenance/send-test-email');
|
||||
$sendReq->assertRedirect('/settings/maintenance#image-cleanup');
|
||||
@@ -37,7 +37,7 @@ class TestEmailTest extends TestCase
|
||||
$exception = new \Exception('A random error occurred when testing an email');
|
||||
$mockDispatcher->shouldReceive('sendNow')->andThrow($exception);
|
||||
|
||||
$admin = $this->getAdmin();
|
||||
$admin = $this->users->admin();
|
||||
$sendReq = $this->actingAs($admin)->post('/settings/maintenance/send-test-email');
|
||||
$sendReq->assertRedirect('/settings/maintenance#image-cleanup');
|
||||
$this->assertSessionHas('error');
|
||||
@@ -50,12 +50,12 @@ class TestEmailTest extends TestCase
|
||||
public function test_send_test_email_requires_settings_manage_permission()
|
||||
{
|
||||
Notification::fake();
|
||||
$user = $this->getViewer();
|
||||
$user = $this->users->viewer();
|
||||
|
||||
$sendReq = $this->actingAs($user)->post('/settings/maintenance/send-test-email');
|
||||
Notification::assertNothingSent();
|
||||
|
||||
$this->giveUserPermissions($user, ['settings-manage']);
|
||||
$this->permissions->grantUserRolePermissions($user, ['settings-manage']);
|
||||
$sendReq = $this->actingAs($user)->post('/settings/maintenance/send-test-email');
|
||||
Notification::assertSentTo($user, TestEmail::class);
|
||||
}
|
||||
|
Reference in New Issue
Block a user