should be good to go now

This commit is contained in:
spencerrlongg 2024-08-16 12:50:09 -05:00
parent 9622e05cf5
commit dec4691c73
3 changed files with 32 additions and 11 deletions

View file

@ -1072,16 +1072,18 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
}); });
Route::match(['put', 'patch'], '{user}/update', [Api\UsersController::class, 'update'])
->name('api.users.update');
Route::resource('users', Route::resource('users',
Api\UsersController::class, Api\UsersController::class,
['names' => [ ['names' => [
'index' => 'api.users.index', 'index' => 'api.users.index',
'show' => 'api.users.show', 'show' => 'api.users.show',
'update' => 'api.users.update',
'store' => 'api.users.store', 'store' => 'api.users.store',
'destroy' => 'api.users.destroy', 'destroy' => 'api.users.destroy',
], ],
'except' => ['create', 'edit'], 'except' => ['create', 'edit', 'update'],
'parameters' => ['user' => 'user_id'], 'parameters' => ['user' => 'user_id'],
] ]
); // end users API routes ); // end users API routes

View file

@ -365,6 +365,13 @@ class UpdateUserTest extends TestCase
'company_id' => $companyB->id, 'company_id' => $companyB->id,
])->assertStatusMessageIs('success'); ])->assertStatusMessageIs('success');
// same test but PUT
$this->actingAsForApi($superUser)->putJson(route('api.users.update', $user), [
'username' => 'test',
'first_name' => 'Test',
'company_id' => $companyB->id,
])->assertStatusMessageIs('success');
$asset->checkOut($user, $superUser); $asset->checkOut($user, $superUser);
// asset assigned, therefore error // asset assigned, therefore error
@ -372,6 +379,13 @@ class UpdateUserTest extends TestCase
'username' => 'test', 'username' => 'test',
'company_id' => $companyB->id, 'company_id' => $companyB->id,
])->assertStatusMessageIs('error'); ])->assertStatusMessageIs('error');
// same test but PUT
$this->actingAsForApi($superUser)->putJson(route('api.users.update', $user), [
'username' => 'test',
'first_name' => 'Test',
'company_id' => $companyB->id,
])->assertStatusMessageIs('error');
} }
} }

View file

@ -101,14 +101,19 @@ class UpdateUserTest extends TestCase
'first_name' => 'test', 'first_name' => 'test',
'username' => 'test', 'username' => 'test',
'company_id' => $companyB->id, 'company_id' => $companyB->id,
'redirect_option' => 'index'
])->assertRedirect(route('users.index')); ])->assertRedirect(route('users.index'));
//$asset->checkOut($user, $superUser); $asset->checkOut($user, $superUser);
// asset assigned, therefore error // asset assigned, therefore error
//$this->actingAs($superUser)->patchJson(route('users.update', $user), [ $response = $this->actingAs($superUser)->patchJson(route('users.update', $user), [
// 'username' => 'test', 'first_name' => 'test',
// 'company_id' => $companyB->id, 'username' => 'test',
//])->assertMessagesAre('error'); 'company_id' => $companyB->id,
'redirect_option' => 'index'
]);
$this->followRedirects($response)->assertSee('error');
} }
} }