diff --git a/app/Http/Controllers/JudgingController.php b/app/Http/Controllers/JudgingController.php index 292617e..257d611 100644 --- a/app/Http/Controllers/JudgingController.php +++ b/app/Http/Controllers/JudgingController.php @@ -30,10 +30,11 @@ class JudgingController extends Controller public function index() { - $rooms = Auth::user()->judgingAssignments; - $rooms->load('auditions'); + $rooms = Auth::user()->judgingAssignments()->with('auditions')->get(); + $bonusScoresToJudge = Auth::user()->bonusJudgingAssignments()->with('auditions')->get(); - return view('judging.index', compact('rooms')); + //$rooms->load('auditions'); + return view('judging.index', compact('rooms', 'bonusScoresToJudge')); } public function auditionEntryList(Request $request, Audition $audition) diff --git a/resources/views/judging/index.blade.php b/resources/views/judging/index.blade.php index abd34eb..43a655f 100644 --- a/resources/views/judging/index.blade.php +++ b/resources/views/judging/index.blade.php @@ -1,7 +1,8 @@ Judging Dashboard -

Choose auditon to judge

+

Choose + audition to judge

@foreach($rooms as $room) @@ -16,5 +17,20 @@ @endforeach + @foreach($bonusScoresToJudge as $bonusScore) + + {{ $bonusScore->name }} + + @foreach($bonusScore->auditions as $audition) + + + {{ $audition->name }} + + + @endforeach + + + @endforeach +
diff --git a/tests/Feature/Pages/JudgingIndexTest.php b/tests/Feature/Pages/JudgingIndexTest.php index 082b1f7..aedc961 100644 --- a/tests/Feature/Pages/JudgingIndexTest.php +++ b/tests/Feature/Pages/JudgingIndexTest.php @@ -1,6 +1,7 @@ assertDontSee($otherRoom->name) ->assertDontSee($otherAudition->name); }); +it('shows bonus scores the user is assigned to judge', function () { + // Arrange + $bonusScore = BonusScoreDefinition::factory()->create(); + $judge = User::factory()->create(); + $bonusScore->judges()->attach($judge); + $this->actingAs($judge); + // Act & Assert + $this->get(route('judging.index')) + ->assertSee($bonusScore->name); +}); +it('does not show bonus scores the user is not assigned to judge', function () { + // Arrange + $bonusScore = BonusScoreDefinition::factory()->create(); + $otherBonusScore = BonusScoreDefinition::factory()->create(); + $judge = User::factory()->create(); + $bonusScore->judges()->attach($judge); + $this->actingAs($judge); + // Act & Assert + $this->get(route('judging.index')) + ->assertSee($bonusScore->name) + ->assertDontSee($otherBonusScore->name); +}); +it('shows auditions in a bonus score assignment', function () { + // Arrange + $bonusScore = BonusScoreDefinition::factory()->create(); + $audition = Audition::factory()->create(); + $bonusScore->auditions()->attach($audition); + $judge = User::factory()->create(); + $bonusScore->judges()->attach($judge); + $this->actingAs($judge); + // Act & Assert + $this->get(route('judging.index')) + ->assertSee($audition->name); +});