A free open source IT asset/license management system
some more testing stuff
spencerrlongg04d7884af8d9
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.phpindex 4361dc40d8..bc415c0f3d 100644--- a/app/Http/Controllers/Api/AssetsController.php+++ b/app/Http/Controllers/Api/AssetsController.php@@ -631,12 +631,12 @@ class AssetsController extends Controller// it actually breaks at the model validation if it gets to null...($request->validated()['model_id']) ?$asset->model()->associate(AssetModel::find($request->validated()['model_id'])) : null;- ($request->validated()['rtd_location_id']) ?- $asset->location_id = $request->validated()['rtd_location_id'] : '';- ($request->validated()['company_id']) ?- $asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : '';- ($request->validated()['rtd_location_id']) ?- $asset->location_id = $request->validated()['rtd_location_id'] : null;+ //($request->validated()['rtd_location_id']) ?+ // $asset->location_id = $request->validated()['rtd_location_id'] : '';+ //($request->validated()['company_id']) ?+ // $asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : '';+ //($request->validated()['rtd_location_id']) ?+ // $asset->location_id = $request->validated()['rtd_location_id'] : null;/*** this is here just legacy reasons. Api\AssetControllerdiff --git a/app/Models/Asset.php b/app/Models/Asset.phpindex 2e03323d38..303624b427 100644--- a/app/Models/Asset.php+++ b/app/Models/Asset.php@@ -115,12 +115,15 @@ class Asset extends Depreciablepublic function getRulesAttribute(){- $rule = Rule::unique('assets')->ignore($this->id)->withoutTrashed();- $asset = $this->id;return ['model_id' => 'required|integer|exists:models,id,deleted_at,NULL|not_array','status_id' => 'required|integer|exists:status_labels,id',- 'asset_tag' => ['required', 'min:1', 'max:255', Rule::unique('assets', 'asset_tag')->ignore($this->id, 'id')->withoutTrashed()],+ 'asset_tag' => [+ 'required',+ 'min:1',+ 'max:255',+ Rule::unique('assets')->ignore(15)->withoutTrashed()+ ],'name' => 'nullable|max:255','company_id' => 'nullable|integer|exists:companies,id','warranty_months' => 'nullable|numeric|digits_between:0,240',diff --git a/tests/Feature/Api/Assets/AssetStoreTest.php b/tests/Feature/Api/Assets/AssetStoreTest.phpindex 92a58a5006..631944190d 100644--- a/tests/Feature/Api/Assets/AssetStoreTest.php+++ b/tests/Feature/Api/Assets/AssetStoreTest.php@@ -149,9 +149,11 @@ class AssetStoreTest extends TestCase'purchase_date' => '2021-01-01','status_id' => $status->id,])+ //->dd()->assertOk()->assertStatusMessageIs('success')->json();+ return $response;$asset = Asset::find($response['payload']['id']);$this->assertEquals('2024-01-01', $asset->asset_eol_date);