parent
f0b2ec8f68
commit
7a45d4ddbc
|
|
@ -10,8 +10,6 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
use function abort;
|
use function abort;
|
||||||
use function array_keys;
|
|
||||||
use function compact;
|
|
||||||
use function redirect;
|
use function redirect;
|
||||||
use function request;
|
use function request;
|
||||||
use function response;
|
use function response;
|
||||||
|
|
@ -60,7 +58,7 @@ class AuditionController extends Controller
|
||||||
if (empty($alidData['scoring_guide_id'])) {
|
if (empty($alidData['scoring_guide_id'])) {
|
||||||
$validData['scoring_guide_id'] = 0;
|
$validData['scoring_guide_id'] = 0;
|
||||||
}
|
}
|
||||||
|
// TODO Check if room 0 exists, create if not
|
||||||
Audition::create([
|
Audition::create([
|
||||||
'event_id' => $validData['event_id'],
|
'event_id' => $validData['event_id'],
|
||||||
'name' => $validData['name'],
|
'name' => $validData['name'],
|
||||||
|
|
@ -71,6 +69,7 @@ class AuditionController extends Controller
|
||||||
'for_seating' => $validData['for_seating'],
|
'for_seating' => $validData['for_seating'],
|
||||||
'for_advancement' => $validData['for_advancement'],
|
'for_advancement' => $validData['for_advancement'],
|
||||||
'scoring_guide_id' => $validData['scoring_guide_id'],
|
'scoring_guide_id' => $validData['scoring_guide_id'],
|
||||||
|
'room_id' => 0,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return to_route('admin.auditions.index')->with('success', 'Audition created successfully');
|
return to_route('admin.auditions.index')->with('success', 'Audition created successfully');
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ use App\Models\Audition;
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
use function Pest\Laravel\assertDatabaseHas;
|
||||||
use function Pest\Laravel\get;
|
use function Pest\Laravel\get;
|
||||||
use function Pest\Laravel\post;
|
use function Pest\Laravel\post;
|
||||||
|
|
||||||
|
|
@ -112,3 +113,27 @@ it('does not allow a normal user or guest to create an audition', function () {
|
||||||
->assertSessionHas('error', 'You are not authorized to perform this action');
|
->assertSessionHas('error', 'You are not authorized to perform this action');
|
||||||
expect(Audition::count())->toBe($precount);
|
expect(Audition::count())->toBe($precount);
|
||||||
});
|
});
|
||||||
|
it('sets room id 0 for a new auditions', function () {
|
||||||
|
// Arrange
|
||||||
|
$newEvent = Event::factory()->create();
|
||||||
|
$changes = [
|
||||||
|
'event_id' => $newEvent->id,
|
||||||
|
'name' => 'New Name',
|
||||||
|
'entry_deadline' => '1978-01-01',
|
||||||
|
'entry_fee' => 10000,
|
||||||
|
'minimum_grade' => 3,
|
||||||
|
'maximum_grade' => 8,
|
||||||
|
'for_advancement' => 'on',
|
||||||
|
];
|
||||||
|
actAsAdmin();
|
||||||
|
// Act
|
||||||
|
$response = post(route('admin.auditions.store'), $changes);
|
||||||
|
// Assert
|
||||||
|
/** @noinspection PhpUnhandledExceptionInspection */
|
||||||
|
$response->assertRedirect(route('admin.auditions.index'))
|
||||||
|
->assertSessionHasNoErrors()
|
||||||
|
->assertSessionHas('success', 'Audition created successfully');
|
||||||
|
$checkAudition = Audition::latest()->first();
|
||||||
|
expect($checkAudition->room_id)->toBe(0);
|
||||||
|
assertDatabaseHas('rooms', ['id' => 0]);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue