Removed unused DoublerDecision

This commit is contained in:
Matt Young 2025-07-14 14:24:44 -05:00
parent 1cc43c1bce
commit 5e9c7a5084
2 changed files with 97 additions and 1 deletions

View File

@ -34,7 +34,11 @@ class DoublerDecisionController extends Controller
// $doublerEntry->addFlag('declined'); // $doublerEntry->addFlag('declined');
// } // }
// } // }
try {
$this->decider->accept($entry); $this->decider->accept($entry);
} catch (AuditionAdminException $e) {
return redirect()->back()->with('error', $e->getMessage());
}
$returnMessage = $entry->student->full_name().' accepted seating in '.$entry->audition->name; $returnMessage = $entry->student->full_name().' accepted seating in '.$entry->audition->name;
$this->clearCache($entry); $this->clearCache($entry);

View File

@ -0,0 +1,92 @@
<?php
use App\Models\Audition;
use App\Models\Entry;
use App\Models\EntryTotalScore;
use App\Models\Event;
use App\Models\Student;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
beforeEach(function () {
$this->event = Event::factory()->create();
$this->ASaudition = Audition::factory()->create(['event_id' => $this->event->id, 'name' => 'Alto Sax']);
$this->TSaudition = Audition::factory()->create(['event_id' => $this->event->id, 'name' => 'Tenor Sax']);
$this->BSaudition = Audition::factory()->create(['event_id' => $this->event->id, 'name' => 'Bari Sax']);
$this->student = Student::factory()->create();
$this->ASentry = Entry::factory()->create([
'audition_id' => $this->ASaudition->id, 'student_id' => $this->student->id,
]);
$this->TSentry = Entry::factory()->create([
'audition_id' => $this->TSaudition->id, 'student_id' => $this->student->id,
]);
$this->BSentry = Entry::factory()->create([
'audition_id' => $this->BSaudition->id, 'student_id' => $this->student->id,
]);
DB::table('entry_total_scores')->insert([
'entry_id' => $this->ASentry->id,
'seating_total' => 34,
'advancement_total' => 4,
'seating_subscore_totals' => json_encode([22, 2]),
'advancement_subscore_totals' => json_encode([22, 2]),
]);
DB::table('entry_total_scores')->insert([
'entry_id' => $this->TSentry->id,
'seating_total' => 34,
'advancement_total' => 4,
'seating_subscore_totals' => json_encode([22, 2]),
'advancement_subscore_totals' => json_encode([22, 2]),
]);
DB::table('entry_total_scores')->insert([
'entry_id' => $this->BSentry->id,
'seating_total' => 34,
'advancement_total' => 4,
'seating_subscore_totals' => json_encode([22, 2]),
'advancement_subscore_totals' => json_encode([22, 2]),
]);
});
describe('DoublerDecisionController::accept', function () {
it('denies access to normal users and guests', function () {
$this->post(route('doubler.accept', $this->ASentry))->assertRedirect(route('home'));
actAsNormal();
$this->post(route('doubler.accept', $this->ASentry))->assertRedirect(route('dashboard'));
});
it('can accept an entry', function () {
actAsAdmin();
$response = $this->post(route('doubler.accept', $this->ASentry));
$response->assertRedirect()->assertSessionHas('success');
expect($this->ASentry->fresh()->hasFlag('declined'))->toBeFalse();
expect($this->TSentry->fresh()->hasFlag('declined'))->toBeTrue();
expect($this->BSentry->fresh()->hasFlag('declined'))->toBeTrue();
});
it('catches exceptions for invalid requests', function () {
actAsAdmin();
EntryTotalScore::truncate();
$response = $this->post(route('doubler.accept', $this->ASentry));
$response->assertRedirect()->assertSessionHas('error');
});
});
describe('DoublerDecisionController::decline', function () {
it('denies access to normal users and guests', function () {
$this->post(route('doubler.decline', $this->ASentry))->assertRedirect(route('home'));
actAsNormal();
$this->post(route('doubler.decline', $this->ASentry))->assertRedirect(route('dashboard'));
});
it('can decline an entry', function () {
actAsAdmin();
$response = $this->post(route('doubler.decline', $this->ASentry));
$response->assertRedirect()->assertSessionHas('success');
expect($this->ASentry->fresh()->hasFlag('declined'))->toBeTrue();
expect($this->TSentry->fresh()->hasFlag('declined'))->toBeFalse();
expect($this->BSentry->fresh()->hasFlag('declined'))->toBeFalse();
});
it('catches exceptions for invalid requests', function () {
actAsAdmin();
EntryTotalScore::truncate();
$response = $this->post(route('doubler.decline', $this->ASentry));
$response->assertRedirect()->assertSessionHas('error');
});
});