diff --git a/app/Http/Controllers/AppFunctionsController.php b/app/Http/Controllers/AppFunctionsController.php index a70d7ebc..f045a78b 100644 --- a/app/Http/Controllers/AppFunctionsController.php +++ b/app/Http/Controllers/AppFunctionsController.php @@ -174,14 +174,12 @@ class AppFunctionsController extends Controller /** * Get single page content * - * @param $slug + * @param Page $page * @return PageResource */ - public function get_page($slug) + public function get_page(Page $page) { - return new PageResource( - Page::where('slug', $slug)->first() - ); + return new PageResource($page); } /** diff --git a/routes/api.php b/routes/api.php index c08a7287..effff462 100644 --- a/routes/api.php +++ b/routes/api.php @@ -13,7 +13,7 @@ use App\Http\Controllers\Sharing\FileSharingController; // Pages Route::post('/contact', [AppFunctionsController::class, 'contact_form']); -Route::get('/page/{slug}', [AppFunctionsController::class, 'get_page']); +Route::get('/page/{page}', [AppFunctionsController::class, 'get_page']); Route::get('/content', [AppFunctionsController::class, 'get_settings']); // Stripe diff --git a/tests/Feature/App/AppTest.php b/tests/Feature/App/AppTest.php index b4e12446..247c3805 100644 --- a/tests/Feature/App/AppTest.php +++ b/tests/Feature/App/AppTest.php @@ -36,6 +36,20 @@ class AppTest extends TestCase ->assertStatus(200); } + /** + * @test + */ + public function it_get_legal_page() + { + $this->setup->seed_default_pages(); + + $this->getJson('/api/page/terms-of-service') + ->assertStatus(200) + ->assertJsonFragment([ + 'title' => 'Terms of Service', + ]); + } + /** * @test */ @@ -44,7 +58,7 @@ class AppTest extends TestCase Mail::fake(); Setting::create([ - 'name' => 'contact_email', + 'name' => 'contact_email', 'value' => 'jane@doe.com', ]); @@ -54,6 +68,6 @@ class AppTest extends TestCase ]) ->assertStatus(201); - Mail::assertSent( SendContactMessage::class); + Mail::assertSent(SendContactMessage::class); } }