]> BookStack Code Mirror - bookstack/commitdiff
Fixed issue where user id still used on profile pages
authorDan Brown <redacted>
Wed, 4 Aug 2021 20:08:51 +0000 (21:08 +0100)
committerDan Brown <redacted>
Wed, 4 Aug 2021 20:08:51 +0000 (21:08 +0100)
Updated to use slugs and added testing to cover.

resources/views/users/profile.blade.php
tests/User/UserProfileTest.php

index 4028b5c1da731c45925d8d27caea334b46cc0e74..5a76a222a7042eed59fb9151fb909ec7269dad98 100644 (file)
@@ -60,7 +60,7 @@
                     <h2 id="recent-pages" class="list-heading">
                         {{ trans('entities.recently_created_pages') }}
                         @if (count($recentlyCreated['pages']) > 0)
-                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:page}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->slug.'} {type:page}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['pages']) > 0)
@@ -74,7 +74,7 @@
                     <h2 id="recent-chapters" class="list-heading">
                         {{ trans('entities.recently_created_chapters') }}
                         @if (count($recentlyCreated['chapters']) > 0)
-                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:chapter}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->slug.'} {type:chapter}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['chapters']) > 0)
@@ -88,7 +88,7 @@
                     <h2 id="recent-books" class="list-heading">
                         {{ trans('entities.recently_created_books') }}
                         @if (count($recentlyCreated['books']) > 0)
-                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:book}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->slug.'} {type:book}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['books']) > 0)
                     <h2 id="recent-shelves" class="list-heading">
                         {{ trans('entities.recently_created_shelves') }}
                         @if (count($recentlyCreated['shelves']) > 0)
-                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->id.'} {type:bookshelf}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
+                            <a href="{{ url('/search?term=' . urlencode('{created_by:'.$user->slug.'} {type:bookshelf}') ) }}" class="text-small ml-s">{{ trans('common.view_all') }}</a>
                         @endif
                     </h2>
                     @if (count($recentlyCreated['shelves']) > 0)
index a5db83c48e78816ed4af15402f8c5185209272b5..c87996669877699351d165616991f7f2cfc338f1 100644 (file)
@@ -83,6 +83,23 @@ class UserProfileTest extends BrowserKitTest
             ->see($newUser->name);
     }
 
+    public function test_profile_has_search_links_in_created_entity_lists()
+    {
+        $user = $this->getEditor();
+        $resp = $this->actingAs($this->getAdmin())->visit('/user/' . $user->slug);
+
+        $expectedLinks = [
+            '/search?term=%7Bcreated_by%3A' . $user->slug . '%7D+%7Btype%3Apage%7D',
+            '/search?term=%7Bcreated_by%3A' . $user->slug . '%7D+%7Btype%3Achapter%7D',
+            '/search?term=%7Bcreated_by%3A' . $user->slug . '%7D+%7Btype%3Abook%7D',
+            '/search?term=%7Bcreated_by%3A' . $user->slug . '%7D+%7Btype%3Abookshelf%7D',
+        ];
+
+        foreach ($expectedLinks as $link) {
+            $resp->seeInElement('[href$="' . $link . '"]', 'View All');
+        }
+    }
+
     public function test_guest_profile_shows_limited_form()
     {
         $this->asAdmin()