mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
change keys to values, add test
This commit is contained in:
parent
19cff25300
commit
25480293dc
|
@ -214,7 +214,7 @@ class BulkAssetsController extends Controller
|
|||
}
|
||||
|
||||
|
||||
$assets = Asset::whereIn('id', array_keys($request->input('ids')))->get();
|
||||
$assets = Asset::whereIn('id', $request->input('ids'))->get();
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -196,8 +196,8 @@
|
|||
|
||||
@include("models/custom_fields_form_bulk_edit",["models" => $models])
|
||||
|
||||
@foreach ($assets as $key => $value)
|
||||
<input type="hidden" name="ids[{{ $value }}]" value="1">
|
||||
@foreach($assets as $asset)
|
||||
<input type="hidden" name="ids[]" value="{{ $asset }}">
|
||||
@endforeach
|
||||
</div> <!--/.box-body-->
|
||||
|
||||
|
|
33
tests/Feature/Assets/AssetsBulkEditTest.php
Normal file
33
tests/Feature/Assets/AssetsBulkEditTest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\Assets;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AssetsBulkEditTest extends TestCase
|
||||
{
|
||||
public function testBulkEditAsset()
|
||||
{
|
||||
$assets = Asset::factory()->count(10)->create(['purchase_date' => '2023-01-01']);
|
||||
|
||||
$id_array = $assets->pluck('id')->toArray();
|
||||
|
||||
$response = $this->actingAs(User::factory()->editAssets()->create())->post(route('hardware/bulksave'), [
|
||||
'ids' => array_values($id_array),
|
||||
'purchase_date' => '2024-01-01'
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
Asset::findMany($id_array)->each(function (Asset $asset) {
|
||||
$this->assertEquals('2024-01-01', $asset->purchase_date->format('Y-m-d'));
|
||||
});
|
||||
|
||||
$this->assertDatabaseHas('assets', [
|
||||
'purchase_date' => '2024-01-01'
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue