From 5e9c7a5084546b1d346aaf40adf0a12abe6916ae Mon Sep 17 00:00:00 2001 From: Matt Young Date: Mon, 14 Jul 2025 14:24:44 -0500 Subject: [PATCH] Removed unused DoublerDecision --- .../Tabulation/DoublerDecisionController.php | 6 +- .../DoublerDecisionControllerTest.php | 92 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/app/Http/Controllers/Tabulation/DoublerDecisionControllerTest.php diff --git a/app/Http/Controllers/Tabulation/DoublerDecisionController.php b/app/Http/Controllers/Tabulation/DoublerDecisionController.php index b9f876f..fa4dd7d 100644 --- a/app/Http/Controllers/Tabulation/DoublerDecisionController.php +++ b/app/Http/Controllers/Tabulation/DoublerDecisionController.php @@ -34,7 +34,11 @@ class DoublerDecisionController extends Controller // $doublerEntry->addFlag('declined'); // } // } - $this->decider->accept($entry); + try { + $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; $this->clearCache($entry); diff --git a/tests/Feature/app/Http/Controllers/Tabulation/DoublerDecisionControllerTest.php b/tests/Feature/app/Http/Controllers/Tabulation/DoublerDecisionControllerTest.php new file mode 100644 index 0000000..f7564f5 --- /dev/null +++ b/tests/Feature/app/Http/Controllers/Tabulation/DoublerDecisionControllerTest.php @@ -0,0 +1,92 @@ +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'); + }); +});