Skip to content

NOW MANAGED ON CODEBERG

Notifications: Fixed issues causing failing tests

Dan Brownee9e342b58a5
diff --git a/app/Users/Models/User.php b/app/Users/Models/User.php
index 08cab69fb..be3e9b9b3 100644
--- a/app/Users/Models/User.php
+++ b/app/Users/Models/User.php
@@ -88,8 +88,6 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
/**
* This holds the default user when loaded.
- *
- * @var null|User
*/
protected static ?User $defaultUser = null;
@@ -107,6 +105,11 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
return static::$defaultUser;
}
+ public static function clearDefault(): void
+ {
+ static::$defaultUser = null;
+ }
+
/**
* Check if the user is the default public user.
*/
diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php
index 0fb98e304..75b01a379 100644
--- a/resources/views/books/show.blade.php
+++ b/resources/views/books/show.blade.php
@@ -70,7 +70,7 @@
<div class="mb-xl">
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
- @include('entities.meta', ['entity' => $book])
+ @include('entities.meta', ['entity' => $book, 'watchOptions' => $watchOptions])
@if($book->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $book))
diff --git a/resources/views/chapters/show.blade.php b/resources/views/chapters/show.blade.php
index 67a8b9fa5..3cb512ccc 100644
--- a/resources/views/chapters/show.blade.php
+++ b/resources/views/chapters/show.blade.php
@@ -67,7 +67,7 @@
<div class="mb-xl">
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
- @include('entities.meta', ['entity' => $chapter])
+ @include('entities.meta', ['entity' => $chapter, 'watchOptions' => $watchOptions])
@if($book->hasPermissions())
<div class="active-restriction">
diff --git a/resources/views/pages/revision.blade.php b/resources/views/pages/revision.blade.php
index b3208c211..c0831ef59 100644
--- a/resources/views/pages/revision.blade.php
+++ b/resources/views/pages/revision.blade.php
@@ -4,7 +4,7 @@
<div id="revision-details" class="entity-details mb-xl">
<h5>{{ trans('common.details') }}</h5>
<div class="body text-small text-muted">
- @include('entities.meta', ['entity' => $revision])
+ @include('entities.meta', ['entity' => $revision, 'watchOptions' => null])
</div>
</div>
@stop
diff --git a/resources/views/pages/show.blade.php b/resources/views/pages/show.blade.php
index 7d44f677d..1cbb81980 100644
--- a/resources/views/pages/show.blade.php
+++ b/resources/views/pages/show.blade.php
@@ -81,7 +81,7 @@
<div id="page-details" class="entity-details mb-xl">
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
- @include('entities.meta', ['entity' => $page])
+ @include('entities.meta', ['entity' => $page, 'watchOptions' => $watchOptions])
@if($book->hasPermissions())
<div class="active-restriction">
diff --git a/resources/views/shelves/show.blade.php b/resources/views/shelves/show.blade.php
index 25b7a14fc..8019a557f 100644
--- a/resources/views/shelves/show.blade.php
+++ b/resources/views/shelves/show.blade.php
@@ -79,7 +79,7 @@
<div id="details" class="mb-xl">
<h5>{{ trans('common.details') }}</h5>
<div class="blended-links">
- @include('entities.meta', ['entity' => $shelf])
+ @include('entities.meta', ['entity' => $shelf, 'watchOptions' => null])
@if($shelf->hasPermissions())
<div class="active-restriction">
@if(userCan('restrictions-manage', $shelf))
diff --git a/tests/Activity/WatchTest.php b/tests/Activity/WatchTest.php
index d68bd271f..e8cb3cbd8 100644
--- a/tests/Activity/WatchTest.php
+++ b/tests/Activity/WatchTest.php
@@ -102,6 +102,7 @@ class WatchTest extends TestCase
]);
$this->assertPermissionError($resp);
+ $guest->unsetRelations();
}
public function test_watch_detail_display_reflects_state()
diff --git a/tests/Helpers/UserRoleProvider.php b/tests/Helpers/UserRoleProvider.php
index 2b7a3623d..3b2da369d 100644
--- a/tests/Helpers/UserRoleProvider.php
+++ b/tests/Helpers/UserRoleProvider.php
@@ -55,7 +55,7 @@ class UserRoleProvider
*/
public function guest(): User
{
- return User::where('system_name', '=', 'public')->firstOrFail();
+ return User::getDefault();
}
/**
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 322ab0370..0ab0792bd 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -5,6 +5,7 @@ namespace Tests;
use BookStack\Entities\Models\Entity;
use BookStack\Settings\SettingService;
use BookStack\Uploads\HttpFetcher;
+use BookStack\Users\Models\User;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
@@ -46,6 +47,7 @@ abstract class TestCase extends BaseTestCase
$this->permissions = new PermissionsProvider($this->users);
$this->files = new FileProvider();
+ User::clearDefault();
parent::setUp();
// We can uncomment the below to run tests with failings upon deprecations.