3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-05 09:35:49 +00:00

Avoid logging consumable checkins

This commit is contained in:
Marcus Moore
2025-03-12 11:48:14 -07:00
parent dbe78c30d5
commit be6caf936e
2 changed files with 16 additions and 20 deletions

View File

@ -298,7 +298,6 @@ class BulkUsersController extends Controller
$this->logItemCheckinAndDelete($assets, Asset::class);
$this->logAccessoriesCheckin($accessoryUserRows);
$this->logItemCheckinAndDelete($licenses, License::class);
$this->logConsumablesCheckin($consumableUserRows);
Asset::whereIn('id', $assets->pluck('id'))->update([
'status_id' => e(request('status_id')),
@ -366,20 +365,6 @@ class BulkUsersController extends Controller
}
}
private function logConsumablesCheckin(Collection $consumableUserRows): void
{
foreach ($consumableUserRows as $consumableUserRow) {
$logAction = new Actionlog();
$logAction->item_id = $consumableUserRow->consumable_id;
$logAction->item_type = Consumable::class;
$logAction->target_id = $consumableUserRow->assigned_to;
$logAction->target_type = User::class;
$logAction->created_by = auth()->id();
$logAction->note = 'Bulk checkin items';
$logAction->logaction('checkin from');
}
}
/**
* Save bulk-edited users
*

View File

@ -146,11 +146,10 @@ class BulkDeleteUsersTest extends TestCase
$this->assertTrue($userB->fresh()->consumables->isNotEmpty());
$this->assertTrue($userC->fresh()->consumables->isEmpty());
// These assertions check against a bug where the wrong value from
// consumables_users was being populated in action_logs.item_id.
$this->assertActionLogCheckInEntryFor($userA, $consumableA);
$this->assertActionLogCheckInEntryFor($userA, $consumableB);
$this->assertActionLogCheckInEntryFor($userC, $consumableA);
// Consumable checkin should not be logged.
$this->assertNoActionLogCheckInEntryFor($userA, $consumableA);
$this->assertNoActionLogCheckInEntryFor($userA, $consumableB);
$this->assertNoActionLogCheckInEntryFor($userC, $consumableA);
}
public function test_license_seats_can_be_bulk_checked_in()
@ -257,4 +256,16 @@ class BulkDeleteUsersTest extends TestCase
'item_id' => $model->id,
]);
}
private function assertNoActionLogCheckInEntryFor(User $user, Model $model): void
{
$this->assertDatabaseMissing('action_logs', [
'action_type' => 'checkin from',
'target_id' => $user->id,
'target_type' => User::class,
'note' => 'Bulk checkin items',
'item_type' => get_class($model),
'item_id' => $model->id,
]);
}
}