mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
most tests now passing, still one broken
This commit is contained in:
parent
c0110e7f29
commit
1e810d2426
|
@ -629,14 +629,12 @@ class AssetsController extends Controller
|
||||||
// this is _always_ filled now, see UpdateAssetRequest
|
// this is _always_ filled now, see UpdateAssetRequest
|
||||||
// i'm leaving it like this for now, but when would we ever want model_id to be `null`??
|
// i'm leaving it like this for now, but when would we ever want model_id to be `null`??
|
||||||
// it actually breaks at the model validation if it gets to null...
|
// it actually breaks at the model validation if it gets to null...
|
||||||
($request->validated()['model_id']) ?
|
($request->has('model_id')) ?
|
||||||
$asset->model()->associate(AssetModel::find($request->validated()['model_id'])) : null;
|
$asset->model()->associate(AssetModel::find($request->validated()['model_id'])) : null;
|
||||||
//($request->validated()['rtd_location_id']) ?
|
($request->has('company_id')) ?
|
||||||
// $asset->location_id = $request->validated()['rtd_location_id'] : '';
|
$asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : null;
|
||||||
//($request->validated()['company_id']) ?
|
($request->has('rtd_location_id')) ?
|
||||||
// $asset->company_id = Company::getIdForCurrentUser($request->validated()['company_id']) : '';
|
$asset->location_id = $request->validated()['rtd_location_id'] : null;
|
||||||
//($request->validated()['rtd_location_id']) ?
|
|
||||||
// $asset->location_id = $request->validated()['rtd_location_id'] : null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is here just legacy reasons. Api\AssetController
|
* this is here just legacy reasons. Api\AssetController
|
||||||
|
|
|
@ -29,13 +29,15 @@ class AssetUpdateTest extends TestCase
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGivenPermissionUpdateAssetIsAllower()
|
public function testGivenPermissionUpdateAssetIsAllowed()
|
||||||
|
|
||||||
{
|
{
|
||||||
$asset = Asset::factory()->create();
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
$this->actingAsForApi(User::factory()->editAssets()->create())
|
$this->actingAsForApi(User::factory()->editAssets()->create())
|
||||||
->patchJson(route('api.assets.update', $asset->id))
|
->patchJson(route('api.assets.update', $asset->id), [
|
||||||
|
'name' => 'test'
|
||||||
|
])
|
||||||
->assertOk();
|
->assertOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,21 +105,20 @@ class AssetUpdateTest extends TestCase
|
||||||
|
|
||||||
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
||||||
{
|
{
|
||||||
$model = AssetModel::factory()->mbp13Model()->create();
|
$asset = Asset::factory()->laptopMbp()->create();
|
||||||
$asset = Asset::factory()->create();
|
|
||||||
|
|
||||||
$this->settings->enableAutoIncrement();
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
||||||
->patchJson((route('api.assets.update', $asset->id)), [
|
->patchJson((route('api.assets.update', $asset->id)), [
|
||||||
'model_id' => $model->id,
|
|
||||||
'purchase_date' => '2021-01-01',
|
'purchase_date' => '2021-01-01',
|
||||||
])
|
])
|
||||||
//->dd()
|
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertStatusMessageIs('success')
|
->assertStatusMessageIs('success')
|
||||||
->json();
|
->json();
|
||||||
|
|
||||||
|
$asset->refresh();
|
||||||
|
|
||||||
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue