Notify transfer owners when files enter grace period.
Deploy Ladill Transfer / deploy (push) Successful in 1m0s
Deploy Ladill Transfer / deploy (push) Successful in 1m0s
Send grace-entered and countdown emails to owners alongside recipient grace milestones so unpaid transfers get clear wallet top-up reminders before deletion. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,9 +4,11 @@ namespace Tests\Feature;
|
||||
|
||||
use App\Models\Transfer;
|
||||
use App\Models\User;
|
||||
use App\Notifications\TransferOwnerGraceNotification;
|
||||
use App\Services\Transfer\TransferBillingService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\Concerns\FakesTransferBilling;
|
||||
use Tests\TestCase;
|
||||
@@ -18,6 +20,8 @@ class TransferBillingTest extends TestCase
|
||||
|
||||
public function test_failed_renewal_enters_grace_period(): void
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$user = User::create([
|
||||
'public_id' => (string) Str::uuid(),
|
||||
'name' => 'Grace User',
|
||||
@@ -46,6 +50,8 @@ class TransferBillingTest extends TestCase
|
||||
$this->assertNotNull($transfer->grace_ends_at);
|
||||
$this->assertTrue($transfer->grace_ends_at->isFuture());
|
||||
$this->assertTrue($transfer->isAccessible());
|
||||
|
||||
Notification::assertSentTo($user, TransferOwnerGraceNotification::class);
|
||||
}
|
||||
|
||||
public function test_transfer_past_grace_period_is_deleted(): void
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Transfer;
|
||||
use App\Models\User;
|
||||
use App\Notifications\TransferOwnerGraceNotification;
|
||||
use App\Services\Transfer\TransferOwnerMailService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TransferOwnerGraceMailTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_owner_grace_day_milestone_is_sent_once(): void
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$user = User::create([
|
||||
'public_id' => (string) Str::uuid(),
|
||||
'name' => 'Owner',
|
||||
'email' => 'owner+'.uniqid().'@example.com',
|
||||
]);
|
||||
|
||||
$transfer = Transfer::create([
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Grace reminder',
|
||||
'retention_days' => 30,
|
||||
'paid_until' => now()->subDay(),
|
||||
'grace_ends_at' => now()->addDays(3)->startOfDay(),
|
||||
'status' => Transfer::STATUS_GRACE,
|
||||
'storage_bytes' => 1024,
|
||||
'owner_milestones_sent' => ['grace_entered'],
|
||||
]);
|
||||
|
||||
$service = app(TransferOwnerMailService::class);
|
||||
$this->assertSame(1, $service->processGraceReminders());
|
||||
$this->assertSame(0, $service->processGraceReminders());
|
||||
|
||||
Notification::assertSentTo($user, TransferOwnerGraceNotification::class, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user