mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
105 - Validation and Redirects
This commit is contained in:
@@ -16,6 +16,10 @@ class ConcertsController extends Controller
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'title' => ['required'],
|
||||
]);
|
||||
|
||||
$concert = Concert::create([
|
||||
'title' => request('title'),
|
||||
'subtitle' => request('subtitle'),
|
||||
|
||||
@@ -12,6 +12,12 @@ class AddConcertTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
private function from($url)
|
||||
{
|
||||
session()->setPreviousUrl(url($url));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function promoters_can_view_the_add_concert_form()
|
||||
{
|
||||
@@ -93,4 +99,30 @@ class AddConcertTest extends TestCase
|
||||
$response->assertRedirect('/login');
|
||||
$this->assertEquals(0, Concert::count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function title_is_required()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->from('/backstage/concerts/new')->post('/backstage/concerts', [
|
||||
'title' => '',
|
||||
'subtitle' => 'with Cruel Hand and Backtrack',
|
||||
'additional_information' => "You must be 19 years of age to attend this concert.",
|
||||
'date' => '2017-11-18',
|
||||
'time' => '8:00pm',
|
||||
'venue' => 'The Mosh Pit',
|
||||
'venue_address' => '123 Fake St.',
|
||||
'city' => 'Laraville',
|
||||
'state' => 'ON',
|
||||
'zip' => '12345',
|
||||
'ticket_price' => '32.50',
|
||||
'ticket_quantity' => '75',
|
||||
]);
|
||||
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('/backstage/concerts/new');
|
||||
$response->assertSessionHasErrors('title');
|
||||
$this->assertEquals(0, Concert::count());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user