mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
buncha progress
This commit is contained in:
parent
f6ab0f8f46
commit
86ab880c90
|
@ -48,6 +48,7 @@ class AssetFactory extends Factory
|
|||
'assigned_type' => null,
|
||||
'next_audit_date' => null,
|
||||
'last_checkout' => null,
|
||||
'asset_eol_date' => null
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -352,4 +353,14 @@ class AssetFactory extends Factory
|
|||
{
|
||||
return $this->state(['requestable' => false]);
|
||||
}
|
||||
|
||||
public function noPurchaseOrEolDate()
|
||||
{
|
||||
return $this->afterCreating(function (Asset $asset) {
|
||||
$asset->update([
|
||||
'purchase_date' => null,
|
||||
'asset_eol_date' => null
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,6 @@ class AssetStoreTest extends TestCase
|
|||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->json();
|
||||
return $response;
|
||||
|
||||
$asset = Asset::find($response['payload']['id']);
|
||||
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||
|
|
|
@ -27,6 +27,16 @@ class AssetUpdateTest extends TestCase
|
|||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testGivenPermissionUpdateAssetIsAllower()
|
||||
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->actingAsForApi(User::factory()->editAssets()->create())
|
||||
->patchJson(route('api.assets.update', $asset->id))
|
||||
->assertOk();
|
||||
}
|
||||
|
||||
public function testAllAssetAttributesAreStored()
|
||||
{
|
||||
$asset = Asset::factory()->create();
|
||||
|
@ -89,29 +99,44 @@ class AssetUpdateTest extends TestCase
|
|||
$this->assertEquals(10, $updatedAsset->warranty_months);
|
||||
}
|
||||
|
||||
public function testArchivedDepreciateAndPhysicalCanBeNull()
|
||||
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
||||
{
|
||||
$model = AssetModel::factory()->ipadModel()->create();
|
||||
$status = Statuslabel::factory()->create();
|
||||
$model = AssetModel::factory()->mbp13Model()->create();
|
||||
$asset = Asset::factory()->create();
|
||||
|
||||
$this->settings->enableAutoIncrement();
|
||||
|
||||
$response = $this->actingAsForApi(User::factory()->superuser()->create())
|
||||
->patchJson(route('api.assets.update', $asset->id), [
|
||||
'archive' => null,
|
||||
'depreciate' => null,
|
||||
'physical' => null
|
||||
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
||||
->patchJson((route('api.assets.update', $asset->id)), [
|
||||
'model_id' => $model->id,
|
||||
'purchase_date' => '2021-01-01',
|
||||
])
|
||||
->dd()
|
||||
//->dd()
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->json();
|
||||
|
||||
$asset = Asset::find($response['payload']['id']);
|
||||
$this->assertEquals(0, $asset->archived);
|
||||
$this->assertEquals(1, $asset->physical);
|
||||
$this->assertEquals(0, $asset->depreciate);
|
||||
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||
}
|
||||
|
||||
public function testAssetEolDateIsNotCalculatedIfPurchaseDateNotSet()
|
||||
{
|
||||
$asset = Asset::factory()->laptopMbp()->noPurchaseOrEolDate()->create();
|
||||
|
||||
$this->settings->enableAutoIncrement();
|
||||
|
||||
$response = $this->actingAsForApi(User::factory()->editAssets()->create())
|
||||
->patchJson(route('api.assets.update', $asset->id), [
|
||||
'name' => 'test asset',
|
||||
'asset_eol_date' => '2022-01-01'
|
||||
])
|
||||
->assertOk()
|
||||
->assertStatusMessageIs('success')
|
||||
->json();
|
||||
|
||||
$asset->refresh();
|
||||
|
||||
$this->assertEquals('2022-01-01', $asset->asset_eol_date);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue