location update bug fix and test
This commit is contained in:
parent
0d6a83197a
commit
cd10cd34f4
2 changed files with 23 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue