fix: isolate tick errors per event, bound overlap lock

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
nikita.hohlov
2026-09-04 07:46:35 -03:00
parent affac4ce1a
commit 6138ac7bb0
3 changed files with 37 additions and 2 deletions

View File

@@ -18,6 +18,8 @@ use App\Models\User;
use Carbon\CarbonImmutable;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Tests\Support\FakeChannel;
use Tests\Support\FakeRegistry;
use Tests\TestCase;
@@ -187,4 +189,27 @@ class TickTest extends TestCase
$this->webhook->presence = Presence::Absent;
$this->assertSame(Presence::Present, Cache::get('presence:'.Channel::where('type', 'webhook')->sole()->id));
}
public function test_poison_event_does_not_stop_the_pass(): void
{
Log::spy();
$poison = User::create(['login' => 'poison', 'tz' => 'UTC', 'quiet_start' => '22:00:00', 'quiet_end' => '09:00:00']);
DB::table('users')->where('id', $poison->id)->update(['tz' => 'Not/AZone']);
Channel::create(['user_id' => $poison->id, 'type' => ChannelType::Webhook, 'config' => ['deliver_url' => 'u', 'presence_url' => 'p'], 'enabled' => true]);
Event::create([
'source_id' => $this->source->id, 'user_id' => $poison->id, 'source_ref' => 'r', 'topic' => uniqid(),
'due_mode' => DueMode::Local, 'due_date' => '2026-09-30', 'due_time' => '24:00:00', 'fire_on' => '2026-08-31',
'after_due' => AfterDue::Keep, 'payload' => ['title' => 'T'], 'state' => EventState::Scheduled,
'quiet_until' => CarbonImmutable::parse('2000-01-01Z'),
]);
$this->event('2026-09-30', '2026-08-31');
$this->webhook->presence = Presence::Present;
$this->tickAt('2026-09-05T10:00:00Z');
$this->assertSame(1, Delivery::count(), 'здоровое событие доставлено, несмотря на отравленное');
Log::shouldHaveReceived('error')->once();
}
}