Add guest policy settings
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Jobs\Packages\SendEventPackagePhotoThresholdWarning;
|
||||
use App\Models\Emotion;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventPackage;
|
||||
use App\Models\GuestPolicySetting;
|
||||
use App\Models\MediaStorageTarget;
|
||||
use App\Models\Package;
|
||||
use App\Models\Photo;
|
||||
@@ -213,6 +214,43 @@ class EventGuestUploadLimitTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_guest_policy_overrides_device_upload_limit(): void
|
||||
{
|
||||
GuestPolicySetting::flushCache();
|
||||
GuestPolicySetting::query()->create([
|
||||
'id' => 1,
|
||||
'per_device_upload_limit' => 2,
|
||||
]);
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
$event = Event::factory()->for($tenant)->create([
|
||||
'status' => 'published',
|
||||
]);
|
||||
|
||||
$mock = \Mockery::mock(PackageLimitEvaluator::class);
|
||||
$mock->shouldReceive('assessPhotoUpload')->andReturn(null);
|
||||
$mock->shouldReceive('resolveEventPackageForPhotoUpload')->andReturn(null);
|
||||
$this->instance(PackageLimitEvaluator::class, $mock);
|
||||
|
||||
Photo::factory()->count(2)->for($event)->create([
|
||||
'guest_name' => 'device-limit',
|
||||
]);
|
||||
|
||||
$emotion = Emotion::factory()->create();
|
||||
$emotion->eventTypes()->attach($event->event_type_id);
|
||||
|
||||
$token = app(EventJoinTokenService::class)->createToken($event)->plain_token;
|
||||
|
||||
$response = $this->post("/api/v1/events/{$token}/upload", [
|
||||
'photo' => UploadedFile::fake()->image('limit-device.jpg', 800, 600),
|
||||
], [
|
||||
'X-Device-Id' => 'device-limit',
|
||||
]);
|
||||
|
||||
$response->assertStatus(429);
|
||||
$response->assertJsonPath('error.meta.limit', 2);
|
||||
}
|
||||
|
||||
public function test_photo_limit_violation_creates_notification(): void
|
||||
{
|
||||
$tenant = Tenant::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user