Merge pull request #16682 from akemidx/bug/sc-28860
FIXED: Location Being Overwritten By Default Location
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user