diff --git a/src/CachetCoreServiceProvider.php b/src/CachetCoreServiceProvider.php index 4b9b8327..01ab9ead 100644 --- a/src/CachetCoreServiceProvider.php +++ b/src/CachetCoreServiceProvider.php @@ -324,7 +324,7 @@ private function registerSchedules(): void $schedule = $this->app->make(\Illuminate\Console\Scheduling\Schedule::class); $demoMode = fn () => Cachet::demoMode(); - $schedule->command('cachet:beacon')->daily(); + $schedule->command('cachet:beacon')->daily()->when(fn () => config('cachet.beacon')); $schedule->command('cachet:notify-long-running-incidents')->hourly(); diff --git a/tests/Feature/ProviderConfigTest.php b/tests/Feature/ProviderConfigTest.php index 92086108..ca7e8af9 100644 --- a/tests/Feature/ProviderConfigTest.php +++ b/tests/Feature/ProviderConfigTest.php @@ -17,6 +17,15 @@ expect($commands->filter(fn (string $command) => str_contains($command, 'cachet:beacon')))->not->toBeEmpty(); }); +it('only runs the beacon schedule when the beacon is enabled', function (bool $enabled) { + config()->set('cachet.beacon', $enabled); + + $event = collect(app(Schedule::class)->events()) + ->first(fn ($event) => str_contains($event->command ?? '', 'cachet:beacon')); + + expect($event->filtersPass(app()))->toBe($enabled); +})->with([true, false]); + it('configures safe image upload defaults', function () { expect(config('cachet.uploads')) ->disk->toBe('public')