File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ class="size-5 shrink-0"
82
82
datetime =" 2025-04-09"
83
83
class =" text-sm"
84
84
>
85
- {{ $article -> published_at -> format (' F j, Y' ) } }
85
+ {{ $article -> published_at ? -> format (' F j, Y' ) } }
86
86
</time >
87
87
</div >
88
88
</header >
Original file line number Diff line number Diff line change 3
3
namespace Tests \Feature ;
4
4
5
5
use App \Models \Article ;
6
+ use App \Models \User ;
6
7
use Illuminate \Foundation \Testing \RefreshDatabase ;
8
+ use Illuminate \Support \Facades \Config ;
7
9
use PHPUnit \Framework \Attributes \Test ;
8
10
use Tests \TestCase ;
9
11
@@ -74,4 +76,39 @@ public function scheduled_articles_return_a_404()
74
76
$ this ->get (route ('article ' , $ article ))
75
77
->assertStatus (404 );
76
78
}
79
+
80
+ #[Test]
81
+ public function articles_can_be_previewed_by_admin_users ()
82
+ {
83
+ $ article = Article::factory ()->create ([
84
+ 'published_at ' => null ,
85
+ ]);
86
+
87
+ $ admin = User::factory ()->create ();
88
+ Config::set ('filament.users ' , [$ admin ->email ]);
89
+
90
+ // Visitors
91
+ $ this ->get (route ('article ' , $ article ))
92
+ ->assertStatus (404 );
93
+
94
+ // Admins
95
+ $ this ->actingAs ($ admin )
96
+ ->get (route ('article ' , $ article ))
97
+ ->assertOk ();
98
+ }
99
+
100
+ #[Test]
101
+ public function articles_cant_be_previewed_by_regular_users ()
102
+ {
103
+ $ article = Article::factory ()->create ([
104
+ 'published_at ' => null ,
105
+ ]);
106
+
107
+ $ user = User::factory ()->create ();
108
+
109
+ // Non-admin users
110
+ $ this ->actingAs ($ user )
111
+ ->get (route ('article ' , $ article ))
112
+ ->assertStatus (404 );
113
+ }
77
114
}
You can’t perform that action at this time.
0 commit comments