From 0ffceb96918503fdd50fb677339f2ec854f07239 Mon Sep 17 00:00:00 2001 From: spencerrlongg Date: Wed, 20 Mar 2024 00:07:52 -0500 Subject: [PATCH] some notes and a little progress --- app/Http/Controllers/Api/AssetsController.php | 5 +++-- tests/Feature/Api/Assets/AssetUpdateTest.php | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index f798232a7..f3715ce6a 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -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 diff --git a/tests/Feature/Api/Assets/AssetUpdateTest.php b/tests/Feature/Api/Assets/AssetUpdateTest.php index c134c70db..76f4a027f 100644 --- a/tests/Feature/Api/Assets/AssetUpdateTest.php +++ b/tests/Feature/Api/Assets/AssetUpdateTest.php @@ -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); }