Skip to content

A free open source IT asset/license management system

location update bug fix and test

akemidxcd10cd34f4c5
diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php
index 8356899777..6391a3dd9f 100755
--- a/app/Http/Controllers/Assets/AssetsController.php
+++ b/app/Http/Controllers/Assets/AssetsController.php
@@ -351,11 +351,6 @@ class AssetsController extends Controller
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update with '.$status->getStatuslabelType().' status', date('Y-m-d H:i:s'), $originalValues));
}
- if ($asset->assigned_to == '') {
- $asset->location_id = $request->input('rtd_location_id', null);
- }
-
-
if ($request->filled('image_delete')) {
try {
unlink(public_path().'/uploads/assets/'.$asset->image);
diff --git a/tests/Feature/Assets/Ui/EditAssetTest.php b/tests/Feature/Assets/Ui/EditAssetTest.php
index f443f66400..a2645f7320 100644
--- a/tests/Feature/Assets/Ui/EditAssetTest.php
+++ b/tests/Feature/Assets/Ui/EditAssetTest.php
@@ -102,4 +102,27 @@ class EditAssetTest extends TestCase
}, 1);
}
+ public function testCurrentLocationIsNotUpdatedOnEdit()
+ {
+ $defaultLocation = Location::factory()->create();
+ $currentLocation = Location::factory()->create();
+ $asset = Asset::factory()->create([
+ 'location_id' => $currentLocation->id,
+ 'rtd_location_id' => $defaultLocation->id
+ ]);
+
+ $this->actingAs(User::factory()->viewAssets()->editAssets()->create())
+ ->put(route('hardware.update', $asset), [
+ 'redirect_option' => 'item',
+ 'name' => 'New name',
+ 'asset_tags' => 'New Asset Tag',
+ 'status_id' => $asset->status_id,
+ 'model_id' => $asset->model_id,
+ ]);
+
+ $asset->refresh();
+ $this->assertEquals('New name', $asset->name);
+ $this->assertEquals($currentLocation->id, $asset->location_id);
+ }
+
}