Skip to content

Instantly share code, notes, and snippets.

@colindecarlo
Created November 12, 2016 00:26
Show Gist options
  • Save colindecarlo/0b0d99a0289e3a707eecd9b42f957419 to your computer and use it in GitHub Desktop.
Save colindecarlo/0b0d99a0289e3a707eecd9b42f957419 to your computer and use it in GitHub Desktop.
diff --git a/routes/api.php b/routes/api.php
index 6b907f3..0e8d957 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -13,6 +13,11 @@ use Illuminate\Http\Request;
|
*/
-Route::get('/user', function (Request $request) {
- return $request->user();
-})->middleware('auth:api');
+Route::group(['middleware' => 'auth:api'], function () {
+ Route::get('/user', function (Request $request) {
+ return $request->user();
+ })->name('users.index');
+
+ Route::post('/contacts', 'ContactsController@store')->name('contacts.store');
+});
+
diff --git a/routes/web.php b/routes/web.php
index 13ef7eb..6f65d3e 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -17,4 +17,3 @@ Route::get('/', function () {
Auth::routes();
Route::get('/home', 'HomeController@index');
-Route::post('/contacts', 'ContactsController@store')->name('contacts.store');
diff --git a/tests/Features/UserCanAddAContactTest.php b/tests/Features/UserCanAddAContactTest.php
index af38df2..a8ddb34 100644
--- a/tests/Features/UserCanAddAContactTest.php
+++ b/tests/Features/UserCanAddAContactTest.php
@@ -26,8 +26,8 @@ class UserCanAddAContactTest extends TestCase
'address' => '123 Number St, Some Province, Some Country, Some Postal Code'
];
- $this->actingAs($user)
- ->call(Request::METHOD_POST, route('contacts.store'), $form);
+ $this->actingAs($user, 'api')
+ ->json(Request::METHOD_POST, route('contacts.store'), $form);
$this->assertResponseStatus(Response::HTTP_CREATED);
$contacts = $user->contacts()->with('phoneNumbers')->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment