mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 21:18:11 -04:00
fix(cleanup): delete sessions older than the session lifetime
Closes #7394 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8126a5c128
commit
960471984c
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
@@ -34,3 +35,20 @@ it('deletes all activities older than the retention and keeps newer ones', funct
|
||||
expect(Activity::query()->pluck('id')->sort()->values()->all())
|
||||
->toBe($this->recent->pluck('id')->sort()->values()->all());
|
||||
});
|
||||
|
||||
it('deletes sessions older than the session lifetime', function () {
|
||||
config(['session.lifetime' => 10080]);
|
||||
$insertSession = fn (string $id, int $ageInMinutes) => DB::table('sessions')->insert([
|
||||
'id' => $id,
|
||||
'payload' => '',
|
||||
'last_activity' => now()->subMinutes($ageInMinutes)->timestamp,
|
||||
]);
|
||||
$insertSession('expired', 10080 + 60);
|
||||
$insertSession('active', 10080 - 60);
|
||||
|
||||
$this->artisan('cleanup:database --yes')
|
||||
->expectsOutputToContain('Delete 1 entries from sessions.')
|
||||
->assertSuccessful();
|
||||
|
||||
expect(DB::table('sessions')->pluck('id')->all())->toBe(['active']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user