mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
all tests passing
This commit is contained in:
parent
e1addc5aef
commit
fdf0be09db
|
@ -36,30 +36,29 @@ class UpdateAssetRequest extends ImageUploadRequest
|
||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
$rules = [
|
return [
|
||||||
'model_id' => 'integer|exists:models,id,deleted_at,NULL|not_array',
|
'model_id' => ['integer', 'exists:models,id,deleted_at,NULL', 'not_array'],
|
||||||
'status_id' => 'integer|exists:status_labels,id',
|
'status_id' => ['integer', 'exists:status_labels,id'],
|
||||||
'asset_tag' => ['min:1', 'max:255', 'not_array', Rule::unique('assets', 'asset_tag')->ignore($this->asset)->withoutTrashed()],
|
'asset_tag' => ['min:1', 'max:255', 'not_array', Rule::unique('assets', 'asset_tag')->ignore($this->asset)->withoutTrashed()],
|
||||||
'name' => 'nullable|max:255',
|
'name' => ['nullable', 'max:255'],
|
||||||
'company_id' => 'nullable|integer|exists:companies,id',
|
'company_id' => ['nullable', 'integer', 'exists:companies,id'],
|
||||||
'warranty_months' => 'nullable|numeric|digits_between:0,240',
|
'warranty_months' => ['nullable', 'numeric', 'digits_between:0,240'],
|
||||||
'last_checkout' => 'nullable|date_format:Y-m-d H:i:s',
|
'last_checkout' => ['nullable', 'date_format:Y-m-d H:i:s'],
|
||||||
'expected_checkin' => 'nullable|date',
|
'expected_checkin' => ['nullable', 'date'],
|
||||||
'location_id' => 'nullable|exists:locations,id',
|
'location_id' => ['nullable', 'exists:locations,id'],
|
||||||
'rtd_location_id' => 'nullable|exists:locations,id',
|
'rtd_location_id' => ['nullable', 'exists:locations,id'],
|
||||||
'purchase_date' => 'nullable|date|date_format:Y-m-d',
|
'purchase_date' => ['nullable', 'date', 'date_format:Y-m-d'],
|
||||||
'serial' => 'nullable|unique_undeleted:assets,serial',
|
'serial' => ['nullable', 'unique_undeleted:assets,serial'],
|
||||||
'purchase_cost' => 'nullable|numeric|gte:0',
|
'purchase_cost' => ['nullable', 'numeric', 'gte:0'],
|
||||||
'supplier_id' => 'nullable|exists:suppliers,id',
|
'supplier_id' => ['nullable', 'exists:suppliers,id'],
|
||||||
'asset_eol_date' => 'nullable|date',
|
'asset_eol_date' => ['nullable', 'date'],
|
||||||
'eol_explicit' => 'nullable|boolean',
|
'eol_explicit' => ['nullable', 'boolean'],
|
||||||
'byod' => 'nullable|boolean',
|
'byod' => ['nullable', 'boolean'],
|
||||||
'order_number' => 'nullable|string|max:191',
|
'order_number' => ['nullable', 'string', 'max:191'],
|
||||||
'notes' => 'nullable|string|max:65535',
|
'notes' => ['nullable', 'string', 'max:65535'],
|
||||||
'assigned_to' => 'nullable|integer',
|
'assigned_to' => ['nullable', 'integer'],
|
||||||
'requestable' => 'nullable|boolean',
|
'requestable' => ['nullable', 'boolean'],
|
||||||
|
parent::rules(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $rules;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,10 +105,11 @@ class AssetUpdateTest extends TestCase
|
||||||
|
|
||||||
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
public function testAssetEolDateIsCalculatedIfPurchaseDateUpdated()
|
||||||
{
|
{
|
||||||
$asset = Asset::factory()->laptopMbp()->create();
|
$asset = Asset::factory()->laptopMbp()->noPurchaseOrEolDate()->create();
|
||||||
|
|
||||||
$this->settings->enableAutoIncrement();
|
$this->settings->enableAutoIncrement();
|
||||||
|
|
||||||
|
|
||||||
$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)), [
|
||||||
'purchase_date' => '2021-01-01',
|
'purchase_date' => '2021-01-01',
|
||||||
|
@ -119,7 +120,6 @@ class AssetUpdateTest extends TestCase
|
||||||
|
|
||||||
$asset->refresh();
|
$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);
|
$this->assertEquals('2024-01-01', $asset->asset_eol_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue