From fa26941081865eb1f1e309028f7c026142168d0b Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 7 Jun 2024 12:18:33 -0400 Subject: [PATCH] Load current revision for talk.edit route --- app/Http/Controllers/TalksController.php | 2 +- tests/Feature/TalkTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/TalksController.php b/app/Http/Controllers/TalksController.php index 529f1096..1f97b223 100644 --- a/app/Http/Controllers/TalksController.php +++ b/app/Http/Controllers/TalksController.php @@ -64,7 +64,7 @@ public function store(SaveTalkRequest $request) public function edit($id) { try { - $talk = auth()->user()->talks()->findOrFail($id); + $talk = auth()->user()->talks()->withCurrentRevision()->findOrFail($id); } catch (Exception $e) { Session::flash('error-message', 'Sorry, but that isn\'t a valid URL.'); Log::error($e); diff --git a/tests/Feature/TalkTest.php b/tests/Feature/TalkTest.php index 53b0a89e..6fd8f915 100644 --- a/tests/Feature/TalkTest.php +++ b/tests/Feature/TalkTest.php @@ -360,4 +360,15 @@ function archived_talks_can_be_deleted() $response->assertRedirect('talks'); $this->assertDatabaseMissing('talks', ['id' => $talk->id]); } + + /** @test */ + public function editing_a_talk(): void + { + $talk = Talk::factory()->create(); + + $response = $this->actingAs($talk->author) + ->get(route('talks.edit', $talk)); + + $response->assertSuccessful(); + } }