forked from Hexlet/hexlet-sicp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add activity for finish chapter member
- Loading branch information
Showing
10 changed files
with
88 additions
and
206 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 was deleted.
Oops, something went wrong.
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
15 changes: 15 additions & 0 deletions
15
...grations/2024_03_26_174007_rename_added_activity_log_event_to_multiple_chapters_added.php
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 | ||
|
||
use App\Models\Activity; | ||
use App\Services\ActivityService; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Activity::whereDescription(ActivityService::ACTIVITY_CHAPTER_ADDED)->update([ | ||
'description' => ActivityService::ACTIVITY_MULTIPLE_CHAPTERS_ADDED, | ||
]); | ||
} | ||
}; |
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
51 changes: 51 additions & 0 deletions
51
tests/Feature/Http/Controllers/Chapter/ChapterMemberControllerTest.php
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,51 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Feature\Http\Controllers\Chapter; | ||
|
||
use App\Models\Chapter; | ||
use App\Models\ChapterMember; | ||
use App\Models\User; | ||
use App\Services\ActivityService; | ||
use Database\Seeders\ChaptersTableSeeder; | ||
use Tests\TestCase; | ||
|
||
class ChapterMemberControllerTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->seed([ | ||
ChaptersTableSeeder::class, | ||
]); | ||
} | ||
|
||
public function testFinish(): void | ||
{ | ||
/** @var User $user */ | ||
$user = User::factory()->create(); | ||
$chapter = Chapter::wherePath('1.1.1')->first(); | ||
|
||
$this->actingAs($user); | ||
|
||
$response = $this->put(route('chapters.members.finish', $chapter)); | ||
|
||
$response->assertRedirect(); | ||
$response->assertSessionDoesntHaveErrors(); | ||
|
||
$user->refresh(); | ||
|
||
$chapterMember = ChapterMember::where([ | ||
'chapter_id' => $chapter->id, | ||
'user_id' => $user->id, | ||
])->firstOrFail(); | ||
|
||
$this->assertTrue($chapterMember->isFinished()); | ||
$this->assertDatabaseHas('activity_log', [ | ||
'description' => ActivityService::ACTIVITY_CHAPTER_MEMBER_FINISHED, | ||
'subject_type' => $chapterMember::class, | ||
'subject_id' => $chapterMember->id, | ||
'causer_id' => $user->id, | ||
'causer_type' => $user::class, | ||
]); | ||
} | ||
} |
62 changes: 0 additions & 62 deletions
62
tests/Feature/Http/Controllers/User/UserChapterControllerTest.php
This file was deleted.
Oops, something went wrong.