Skip to content

A free open source IT asset/license management system

should be good to go now

spencerrlonggdec4691c73b2
diff --git a/routes/api.php b/routes/api.php
index 0eb0d834cf..c59654d65d 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -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
diff --git a/tests/Feature/Users/Api/UpdateUserTest.php b/tests/Feature/Users/Api/UpdateUserTest.php
index e7314756dd..4632a80c3d 100644
--- a/tests/Feature/Users/Api/UpdateUserTest.php
+++ b/tests/Feature/Users/Api/UpdateUserTest.php
@@ -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');
}
}
diff --git a/tests/Feature/Users/Ui/UpdateUserTest.php b/tests/Feature/Users/Ui/UpdateUserTest.php
index 31530af7c5..3e6867021f 100644
--- a/tests/Feature/Users/Ui/UpdateUserTest.php
+++ b/tests/Feature/Users/Ui/UpdateUserTest.php
@@ -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');
}
}