-
-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* new users threads delete route * new job to delete user threads * add option in admin panel to delete threads * add new logic on controller to delete threads from user and from banning them * delete_threads param validation when banning user * add checkbox to delete threads or not when banning user * added test suite * wip --------- Co-authored-by: Dries Vints <[email protected]>
- Loading branch information
1 parent
049b35e
commit e8cab52
Showing
8 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Models\User; | ||
|
||
final class DeleteUserThreads | ||
{ | ||
public function __construct(private User $user) {} | ||
|
||
public function handle(): void | ||
{ | ||
$this->user->deleteThreads(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use App\Jobs\DeleteUserThreads; | ||
use App\Models\Thread; | ||
use App\Models\User; | ||
use Illuminate\Foundation\Testing\DatabaseMigrations; | ||
use Tests\TestCase; | ||
|
||
uses(TestCase::class); | ||
uses(DatabaseMigrations::class); | ||
|
||
test('we can delete an user threads', function () { | ||
$user = User::factory()->create(); | ||
|
||
Thread::factory()->for($user, 'authorRelation')->count(5)->create(); | ||
|
||
$this->loginAsAdmin(); | ||
$this->dispatch(new DeleteUserThreads($user)); | ||
|
||
$this->assertDatabaseMissing('threads', ['author_id' => $user->id()]); | ||
}); |