File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public function index()
2020
2121 public function show (Article $ article )
2222 {
23- abort_unless ($ article ->isPublished () || auth ()->user ()?->isAdmin(), 404 );
23+ abort_unless ($ article ->isPublished () || $ article -> isScheduled () || auth ()->user ()?->isAdmin(), 404 );
2424
2525 // Set SEO metadata for the article
2626 SEOTools::setTitle ($ article ->title .' - Blog ' );
Original file line number Diff line number Diff line change @@ -62,6 +62,11 @@ public function isPublished(): bool
6262 return $ this ->published_at && $ this ->published_at ->isPast ();
6363 }
6464
65+ public function isScheduled (): bool
66+ {
67+ return $ this ->published_at && $ this ->published_at ->isFuture ();
68+ }
69+
6570 public function publish (?DateTime $ on = null )
6671 {
6772 if (! $ on ) {
Original file line number Diff line number Diff line change @@ -69,12 +69,12 @@ public function published_articles_are_visitable()
6969 }
7070
7171 #[Test]
72- public function scheduled_articles_return_a_404 ()
72+ public function scheduled_articles_are_visitable_via_direct_link ()
7373 {
7474 $ article = Article::factory ()->scheduled ()->create ();
7575
7676 $ this ->get (route ('article ' , $ article ))
77- ->assertStatus ( 404 );
77+ ->assertOk ( );
7878 }
7979
8080 #[Test]
You can’t perform that action at this time.
0 commit comments