name('home');
Route::get('/admin', function () {
- return view('home');
+ return view('admin.dashboard');
})->middleware(['auth', 'can:access-admin'])->name('admin.dashboard');
diff --git a/tests/Feature/Auth/RbacTest.php b/tests/Feature/Auth/RbacTest.php
index 52d8143..fdbfa81 100644
--- a/tests/Feature/Auth/RbacTest.php
+++ b/tests/Feature/Auth/RbacTest.php
@@ -31,3 +31,20 @@
->get(route('admin.dashboard'))
->assertSuccessful();
});
+
+it('shows the admin toolbar entry only to admins', function (): void {
+ $user = User::factory()->create();
+
+ $this->actingAs($user)
+ ->get(route('home'))
+ ->assertSuccessful()
+ ->assertDontSee('href="'.route('admin.dashboard').'"', false);
+
+ $admin = User::factory()->create();
+ $admin->assign('admin');
+
+ $this->actingAs($admin)
+ ->get(route('home'))
+ ->assertSuccessful()
+ ->assertSee('href="'.route('admin.dashboard').'"', false);
+});