mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-07 04:22:06 +03:00
Notifications: Fixed issues causing failing tests
- Ensured watch options passed in all meta template usage to fix failing scenarios where watch options did not exist. - Fixed testing issue caused by guest user permission caching.
This commit is contained in:
parent
79470ea4b7
commit
ee9e342b58
@ -88,8 +88,6 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This holds the default user when loaded.
|
* This holds the default user when loaded.
|
||||||
*
|
|
||||||
* @var null|User
|
|
||||||
*/
|
*/
|
||||||
protected static ?User $defaultUser = null;
|
protected static ?User $defaultUser = null;
|
||||||
|
|
||||||
@ -107,6 +105,11 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
|||||||
return static::$defaultUser;
|
return static::$defaultUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function clearDefault(): void
|
||||||
|
{
|
||||||
|
static::$defaultUser = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the user is the default public user.
|
* Check if the user is the default public user.
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<div class="mb-xl">
|
<div class="mb-xl">
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $book])
|
@include('entities.meta', ['entity' => $book, 'watchOptions' => $watchOptions])
|
||||||
@if($book->hasPermissions())
|
@if($book->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $book))
|
@if(userCan('restrictions-manage', $book))
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
<div class="mb-xl">
|
<div class="mb-xl">
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $chapter])
|
@include('entities.meta', ['entity' => $chapter, 'watchOptions' => $watchOptions])
|
||||||
|
|
||||||
@if($book->hasPermissions())
|
@if($book->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div id="revision-details" class="entity-details mb-xl">
|
<div id="revision-details" class="entity-details mb-xl">
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="body text-small text-muted">
|
<div class="body text-small text-muted">
|
||||||
@include('entities.meta', ['entity' => $revision])
|
@include('entities.meta', ['entity' => $revision, 'watchOptions' => null])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@stop
|
@stop
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
<div id="page-details" class="entity-details mb-xl">
|
<div id="page-details" class="entity-details mb-xl">
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $page])
|
@include('entities.meta', ['entity' => $page, 'watchOptions' => $watchOptions])
|
||||||
|
|
||||||
@if($book->hasPermissions())
|
@if($book->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
<div id="details" class="mb-xl">
|
<div id="details" class="mb-xl">
|
||||||
<h5>{{ trans('common.details') }}</h5>
|
<h5>{{ trans('common.details') }}</h5>
|
||||||
<div class="blended-links">
|
<div class="blended-links">
|
||||||
@include('entities.meta', ['entity' => $shelf])
|
@include('entities.meta', ['entity' => $shelf, 'watchOptions' => null])
|
||||||
@if($shelf->hasPermissions())
|
@if($shelf->hasPermissions())
|
||||||
<div class="active-restriction">
|
<div class="active-restriction">
|
||||||
@if(userCan('restrictions-manage', $shelf))
|
@if(userCan('restrictions-manage', $shelf))
|
||||||
|
@ -102,6 +102,7 @@ class WatchTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertPermissionError($resp);
|
$this->assertPermissionError($resp);
|
||||||
|
$guest->unsetRelations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_watch_detail_display_reflects_state()
|
public function test_watch_detail_display_reflects_state()
|
||||||
|
@ -55,7 +55,7 @@ class UserRoleProvider
|
|||||||
*/
|
*/
|
||||||
public function guest(): User
|
public function guest(): User
|
||||||
{
|
{
|
||||||
return User::where('system_name', '=', 'public')->firstOrFail();
|
return User::getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ namespace Tests;
|
|||||||
use BookStack\Entities\Models\Entity;
|
use BookStack\Entities\Models\Entity;
|
||||||
use BookStack\Settings\SettingService;
|
use BookStack\Settings\SettingService;
|
||||||
use BookStack\Uploads\HttpFetcher;
|
use BookStack\Uploads\HttpFetcher;
|
||||||
|
use BookStack\Users\Models\User;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Handler\MockHandler;
|
use GuzzleHttp\Handler\MockHandler;
|
||||||
use GuzzleHttp\HandlerStack;
|
use GuzzleHttp\HandlerStack;
|
||||||
@ -46,6 +47,7 @@ abstract class TestCase extends BaseTestCase
|
|||||||
$this->permissions = new PermissionsProvider($this->users);
|
$this->permissions = new PermissionsProvider($this->users);
|
||||||
$this->files = new FileProvider();
|
$this->files = new FileProvider();
|
||||||
|
|
||||||
|
User::clearDefault();
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// We can uncomment the below to run tests with failings upon deprecations.
|
// We can uncomment the below to run tests with failings upon deprecations.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user