mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 07:34:06 -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
|
||||
// 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...
|
||||
($request->validated()['model_id']) ?
|
||||
($request->has('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->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;
|
||||
|
||||
/**
|
||||
* this is here just legacy reasons. Api\AssetController
|
||||
|
|
|
@ -29,13 +29,15 @@ class AssetUpdateTest extends TestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testGivenPermissionUpdateAssetIsAllower()
|
||||
public function testGivenPermissionUpdateAssetIsAllowed()
|
||||
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAsForApi(User::factory()->editAssets()->create())
|
||||
->patchJson(route('api.assets.update', $asset->id))
|
||||
->patchJson(route('api.assets.update', $asset->id), [
|
||||
'name' => 'test'
|
||||
])
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
|
@ -103,21 +105,20 @@ class AssetUpdateTest extends TestCase
|
|||
|
||||
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
||||
{
|
||||
$model = AssetModel::factory()->mbp13Model()->create();
|
||||
$asset = Asset::factory()->create();
|
||||
$asset = Asset::factory()->laptopMbp()->create();
|
||||
|
||||
$this->settings->enableAutoIncrement();
|
||||
|
||||
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
||||
->patchJson((route('api.assets.update', $asset->id)), [
|
||||
'model_id' => $model->id,
|
||||
'purchase_date' => '2021-01-01',
|
||||
])
|
||||
//->dd()
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->json();
|
||||
|
||||
$asset->refresh();
|
||||
|
||||
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue