some notes and a little progress

This commit is contained in:
spencerrlongg 2024-03-20 00:07:52 -05:00
parent 1e810d2426
commit 0ffceb9691
2 changed files with 7 additions and 5 deletions

View file

@ -633,8 +633,9 @@ class AssetsController extends Controller
$asset->model()->associate(AssetModel::find($request->validated()['model_id'])) : null;
($request->has('company_id')) ?
$asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : null;
($request->has('rtd_location_id')) ?
$asset->location_id = $request->validated()['rtd_location_id'] : null;
// TODO: this seems like bad logic maybe? it means that if you submit an rtd_location_id and a location_id in the same request location_id is overwritten with rtd_location_id. seems wrong.
//($request->has('rtd_location_id')) ?
// $asset->location_id = $request->validated()['rtd_location_id'] : null;
/**
* this is here just legacy reasons. Api\AssetController

View file

@ -81,14 +81,14 @@ class AssetUpdateTest extends TestCase
$updatedAsset = Asset::find($response['payload']['id']);
// TODO: this isn't working, i assume `adminuser` is the user that created asset
// maybe i don't need to test this on an update???
//$this->assertTrue($updatedAsset->adminuser->is($user));
$this->assertEquals('2024-06-02', $updatedAsset->asset_eol_date);
$this->assertEquals('random_string', $updatedAsset->asset_tag);
$this->assertEquals($userAssigned->id, $updatedAsset->assigned_to);
$this->assertTrue($updatedAsset->company->is($company));
// TODO: this doesn't work
//$this->assertTrue($updatedAsset->location->is($location));
$this->assertTrue($updatedAsset->location->is($location));
$this->assertTrue($updatedAsset->model->is($model));
$this->assertEquals('A New Asset', $updatedAsset->name);
$this->assertEquals('Some notes', $updatedAsset->notes);
@ -109,7 +109,7 @@ class AssetUpdateTest extends TestCase
$this->settings->enableAutoIncrement();
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
$this->actingAsForApi(User::factory()->editAssets()->create())
->patchJson((route('api.assets.update', $asset->id)), [
'purchase_date' => '2021-01-01',
])
@ -119,6 +119,7 @@ class AssetUpdateTest extends TestCase
$asset->refresh();
// what's the problem here? logic problem? might need to skip this for this PR
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
}