get(route('judging.bonusScore.entry', 1)); $response->assertRedirect(route('home')); }); it('denies access to a user not assigned to judge this bonus score', function () { $bonusScore = BonusScoreDefinition::factory()->create(); $audition = Audition::factory()->create(); $audition->bonusScore()->attach($bonusScore->id); $entry = Entry::factory()->create(['audition_id' => $audition->id]); $room = Room::factory()->create(); $user = User::factory()->create(); $room->addJudge($user->id); actingAs($user); $this->get(route('judging.bonusScore.entry', $entry->id)) ->assertRedirect(route('judging.index')) ->assertSessionHas('error', 'You are not assigned to judge this entry'); }); it('denies access if a score already exists for the entry by the user', function () { $entry = Entry::factory()->create(); $judge = User::factory()->create(); $bonusScoreDefinition = BonusScoreDefinition::factory()->create(); $bonusScoreDefinition->judges()->attach($judge->id); BonusScore::create([ 'entry_id' => $entry->id, 'user_id' => $judge->id, 'originally_scored_entry' => $entry->id, 'score' => 42, ]); actingAs($judge); $this->get(route('judging.bonusScore.entry', $entry)) ->assertRedirect(route('judging.bonusScore.EntryList', $entry->audition)) ->assertSessionHas('error', 'You have already judged that entry'); }); it('has a proper score entry form for a valid request', function () { // Arrange $audition = Audition::factory()->create(); $bonusScore = BonusScoreDefinition::factory()->create(['max_score' => 100]); $bonusScore->auditions()->attach($audition->id); $entry = Entry::factory()->create(['audition_id' => $audition->id]); $judge = User::factory()->create(); $bonusScore->judges()->attach($judge->id); actingAs($judge); // Act & Assert $request = $this->get(route('judging.bonusScore.entry', $entry)); $request->assertOk() ->assertFormExists('#score-entry-for-'.$entry->id, function (AssertForm $form) use ($entry) { $form->hasCSRF() ->hasMethod('POST') ->hasAction(route('judging.bonusScores.recordScore', $entry)) ->containsInput(['name' => 'score']) ->containsButton(['type' => 'submit']); }); });