diff --git a/app/Form/Models/Form.php b/app/Form/Models/Form.php index 7ef62e47..627b594e 100644 --- a/app/Form/Models/Form.php +++ b/app/Form/Models/Form.php @@ -192,6 +192,10 @@ class Form extends Model implements HasMedia public function canRegister(): bool { + if (!$this->is_active) { + return false; + } + if ($this->registration_from && $this->registration_from->gt(now())) { return false; } diff --git a/tests/Feature/Form/FormRegisterActionTest.php b/tests/Feature/Form/FormRegisterActionTest.php index 884ed0d4..a62f0e30 100644 --- a/tests/Feature/Form/FormRegisterActionTest.php +++ b/tests/Feature/Form/FormRegisterActionTest.php @@ -270,6 +270,14 @@ it('testItSavesParticipantAsModel', function () { $this->assertEquals('Abraham', $participants->first()->data['spitzname']); }); + +it('cannot register when event is inactive', function () { + $this->login()->loginNami(); + $form = Form::factory()->isActive(false)->create(); + + $this->register($form, [])->assertJsonValidationErrors(['event' => 'Anmeldung zzt nicht möglich.']); +}); + it('testItCannotRegisterWhenRegistrationFromReached', function () { $this->login()->loginNami(); $form = Form::factory()->registrationFrom(now()->addDay())->create();