1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-04-22 07:52:43 +02:00

Output all links visible for a user when browsing lists (#902)

This commit is contained in:
Kovah 2025-02-11 22:01:27 +01:00
parent b9f93d2e8f
commit eb74ca7891
3 changed files with 13 additions and 7 deletions

View File

@ -84,7 +84,7 @@ class ListController extends Controller
$this->checkOrdering();
$links = $list->links()
->byUser()
->visibleForUser()
->orderBy($this->orderBy, $this->orderDir)
->paginate(getPaginationLimit());

View File

@ -2,6 +2,7 @@
namespace Tests\Controller\Models;
use App\Models\Link;
use App\Models\LinkList;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
@ -140,9 +141,14 @@ class ListControllerTest extends TestCase
public function test_detail_view(): void
{
$this->createTestLists();
$otherUser = User::factory()->create();
$this->get('lists/1')->assertOk()->assertSee('Public List')->assertSee('Public List');
[$list, $list2, $list3, $firstUser] = $this->createTestLists();
Link::factory()->for($firstUser)->create(['title' => 'FirstTestLink'])->lists()->sync([$list->id]);
$this->actingAs($otherUser);
$this->get('lists/1')->assertOk()->assertSee('Public List')->assertSee('Public List')->assertSee('FirstTestLink');
$this->get('lists/2')->assertOk()->assertSee('Internal List')->assertSee('Internal List');
$this->get('lists/3')->assertForbidden();
}

View File

@ -32,7 +32,7 @@ trait PreparesTestData
'created_at' => now()->subMinute(),
]);
return [$link, $link2, $link3];
return [$link, $link2, $link3, $otherUser];
}
public function createTestLists(?User $otherUser = null): array
@ -56,7 +56,7 @@ trait PreparesTestData
'created_at' => now()->subMinute(),
]);
return [$list, $list2, $list3];
return [$list, $list2, $list3, $otherUser];
}
public function createTestTags(?User $otherUser = null): array
@ -80,7 +80,7 @@ trait PreparesTestData
'created_at' => now()->subMinute(),
]);
return [$tag1, $tag2, $tag3];
return [$tag1, $tag2, $tag3, $otherUser];
}
public function createTestNotes(?Link $linkForNotes = null, ?User $otherUser = null): array
@ -102,6 +102,6 @@ trait PreparesTestData
'visibility' => ModelAttribute::VISIBILITY_PRIVATE,
]);
return [$note, $note2, $note3];
return [$note, $note2, $note3, $otherUser];
}
}