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

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

View file

@ -365,6 +365,13 @@ class UpdateUserTest extends TestCase
'company_id' => $companyB->id,
])->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 assigned, therefore error
@ -372,6 +379,13 @@ class UpdateUserTest extends TestCase
'username' => 'test',
'company_id' => $companyB->id,
])->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

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