mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2026-05-18 20:34:52 +00:00
🎉 **Introduce meetup activity management**
- Added `is_active` and `last_event_at` fields to meetups with migration. - Enhanced UI: Display `Aktiv`/`Inaktiv` badges and last event dates across dashboard, tables, and maps. - Introduced `/meetups:update-activity` command to manage activity flags and timestamps. - Validated latitude/longitude to prevent `0,0` inputs in city creation and updates. - Updated factories and tests to include meetup activity states (`active`, `inactive`).
This commit is contained in:
@@ -86,6 +86,40 @@ it('rejects city creation with non-existent country', function () {
|
||||
->assertHasErrors(['country_id' => 'exists']);
|
||||
});
|
||||
|
||||
it('rejects city creation when latitude and longitude are both zero', function () {
|
||||
actingAsUser();
|
||||
|
||||
Livewire::test('cities.create')
|
||||
->set('name', 'Null Island')
|
||||
->set('country_id', $this->country->id)
|
||||
->set('latitude', 0)
|
||||
->set('longitude', 0)
|
||||
->call('createCity')
|
||||
->assertHasErrors(['latitude']);
|
||||
|
||||
expect(City::query()->where('name', 'Null Island')->exists())->toBeFalse();
|
||||
});
|
||||
|
||||
it('rejects city update when latitude and longitude are both zero', function () {
|
||||
$city = City::factory()->create([
|
||||
'name' => 'Berlin Test',
|
||||
'country_id' => $this->country->id,
|
||||
'latitude' => 52.52,
|
||||
'longitude' => 13.405,
|
||||
]);
|
||||
actingAsUser();
|
||||
|
||||
Livewire::test('cities.edit', ['city' => $city])
|
||||
->set('name', 'Berlin Test')
|
||||
->set('country_id', $this->country->id)
|
||||
->set('latitude', 0)
|
||||
->set('longitude', 0)
|
||||
->call('updateCity')
|
||||
->assertHasErrors(['latitude']);
|
||||
|
||||
expect($city->refresh()->latitude)->toEqual(52.52);
|
||||
});
|
||||
|
||||
it('updates an existing city', function () {
|
||||
$city = City::factory()->create(['name' => 'Old Name', 'country_id' => $this->country->id]);
|
||||
actingAsUser();
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\RecurrenceType;
|
||||
use App\Models\Meetup;
|
||||
use App\Models\MeetupEvent;
|
||||
|
||||
it('marks a meetup as active when it has a past event within the last year', function () {
|
||||
$meetup = Meetup::factory()->create(['is_active' => false, 'last_event_at' => null]);
|
||||
MeetupEvent::factory()->create([
|
||||
'meetup_id' => $meetup->id,
|
||||
'start' => now()->subMonths(3),
|
||||
'recurrence_type' => null,
|
||||
]);
|
||||
|
||||
$this->artisan('meetups:update-activity')->assertSuccessful();
|
||||
|
||||
$meetup->refresh();
|
||||
expect($meetup->is_active)->toBeTrue()
|
||||
->and($meetup->last_event_at)->not->toBeNull();
|
||||
});
|
||||
|
||||
it('marks a meetup as inactive when the last event is older than a year and no future event exists', function () {
|
||||
$meetup = Meetup::factory()->create(['is_active' => true, 'last_event_at' => now()]);
|
||||
MeetupEvent::factory()->create([
|
||||
'meetup_id' => $meetup->id,
|
||||
'start' => now()->subYears(2),
|
||||
'recurrence_type' => null,
|
||||
]);
|
||||
|
||||
$this->artisan('meetups:update-activity')->assertSuccessful();
|
||||
|
||||
$meetup->refresh();
|
||||
expect($meetup->is_active)->toBeFalse()
|
||||
->and($meetup->last_event_at)->not->toBeNull();
|
||||
});
|
||||
|
||||
it('keeps a meetup active when it only has a future event', function () {
|
||||
$meetup = Meetup::factory()->create(['is_active' => false, 'last_event_at' => null]);
|
||||
MeetupEvent::factory()->create([
|
||||
'meetup_id' => $meetup->id,
|
||||
'start' => now()->addDays(14),
|
||||
'recurrence_type' => null,
|
||||
]);
|
||||
|
||||
$this->artisan('meetups:update-activity')->assertSuccessful();
|
||||
|
||||
$meetup->refresh();
|
||||
expect($meetup->is_active)->toBeTrue()
|
||||
->and($meetup->last_event_at)->toBeNull();
|
||||
});
|
||||
|
||||
it('keeps a meetup active when a recurring event has no end date', function () {
|
||||
$meetup = Meetup::factory()->create(['is_active' => false, 'last_event_at' => null]);
|
||||
MeetupEvent::factory()->create([
|
||||
'meetup_id' => $meetup->id,
|
||||
'start' => now()->subYears(3),
|
||||
'recurrence_type' => RecurrenceType::Monthly,
|
||||
'recurrence_end_date' => null,
|
||||
]);
|
||||
|
||||
$this->artisan('meetups:update-activity')->assertSuccessful();
|
||||
|
||||
$meetup->refresh();
|
||||
expect($meetup->is_active)->toBeTrue();
|
||||
});
|
||||
|
||||
it('marks a meetup as inactive when no events exist at all', function () {
|
||||
$meetup = Meetup::factory()->create(['is_active' => true, 'last_event_at' => now()]);
|
||||
|
||||
$this->artisan('meetups:update-activity')->assertSuccessful();
|
||||
|
||||
$meetup->refresh();
|
||||
expect($meetup->is_active)->toBeFalse()
|
||||
->and($meetup->last_event_at)->toBeNull();
|
||||
});
|
||||
|
||||
it('marks a meetup as inactive when a recurring event has ended more than a year ago', function () {
|
||||
$meetup = Meetup::factory()->create(['is_active' => true, 'last_event_at' => now()]);
|
||||
MeetupEvent::factory()->create([
|
||||
'meetup_id' => $meetup->id,
|
||||
'start' => now()->subYears(3),
|
||||
'recurrence_type' => RecurrenceType::Monthly,
|
||||
'recurrence_end_date' => now()->subYears(2),
|
||||
]);
|
||||
|
||||
$this->artisan('meetups:update-activity')->assertSuccessful();
|
||||
|
||||
$meetup->refresh();
|
||||
expect($meetup->is_active)->toBeFalse();
|
||||
});
|
||||
Reference in New Issue
Block a user