fix: skip demo reset when demo account is disabled (#626)

## What

`demo:reset` now bails out early with an info message when
`config('app.demo.enabled')` is falsy, instead of rebuilding the demo
account regardless of the `DEMO_ENABLED` flag.

## Why

The `DEMO_ENABLED` config existed but the command ignored it, so a
scheduled reset would recreate demo data on environments where the demo
account is turned off.
This commit is contained in:
Víctor Falcón 2026-07-03 09:27:43 +02:00 committed by GitHub
parent a8d28bfcc1
commit eb31455e60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -40,6 +40,14 @@ class ResetDemoAccountCommand extends Command
public function handle(): int
{
$demoEnabled = config('app.demo.enabled');
if (! $demoEnabled) {
$this->info('Demo account is not enabled');
return self::SUCCESS;
}
$demoEmail = config('app.demo.email');
$demoPassword = config('app.demo.password');

View File

@ -4,11 +4,20 @@ use App\Models\User;
beforeEach(function () {
config(['app.demo' => [
'enabled' => true,
'email' => 'demo@whisper.money',
'password' => 'demo',
]]);
});
test('demo:reset does nothing when the demo account is disabled', function () {
config(['app.demo.enabled' => false]);
$this->artisan('demo:reset')->assertSuccessful();
expect(User::where('email', 'demo@whisper.money')->exists())->toBeFalse();
});
test('demo:reset fails if demo email is not configured', function () {
config(['app.demo.email' => null]);