118 - Updating the Other Tests

This commit is contained in:
Adam Wathan
2017-07-04 10:30:13 -04:00
parent ffee09b62a
commit b144cf5619
3 changed files with 13 additions and 6 deletions

View File

@@ -69,6 +69,9 @@ class ConcertsController extends Controller
public function update($id) public function update($id)
{ {
$concert = Auth::user()->concerts()->findOrFail($id);
abort_if($concert->isPublished(), 403);
$this->validate(request(), [ $this->validate(request(), [
'title' => ['required'], 'title' => ['required'],
'date' => ['required', 'date'], 'date' => ['required', 'date'],
@@ -82,10 +85,6 @@ class ConcertsController extends Controller
'ticket_quantity' => ['required', 'integer', 'min:1'], 'ticket_quantity' => ['required', 'integer', 'min:1'],
]); ]);
$concert = Auth::user()->concerts()->findOrFail($id);
abort_if($concert->isPublished(), 403);
$concert->update([ $concert->update([
'title' => request('title'), 'title' => request('title'),
'subtitle' => request('subtitle'), 'subtitle' => request('subtitle'),

View File

@@ -31,14 +31,15 @@ $factory->define(App\Concert::class, function (Faker\Generator $faker) {
}, },
'title' => 'Example Band', 'title' => 'Example Band',
'subtitle' => 'with The Fake Openers', 'subtitle' => 'with The Fake Openers',
'additional_information' => 'Some sample additional information.',
'date' => Carbon::parse('+2 weeks'), 'date' => Carbon::parse('+2 weeks'),
'ticket_price' => 2000,
'venue' => 'The Example Theatre', 'venue' => 'The Example Theatre',
'venue_address' => '123 Example Lane', 'venue_address' => '123 Example Lane',
'city' => 'Fakeville', 'city' => 'Fakeville',
'state' => 'ON', 'state' => 'ON',
'zip' => '90210', 'zip' => '90210',
'additional_information' => 'Some sample additional information.', 'ticket_price' => 2000,
'ticket_quantity' => 5,
]; ];
}); });

View File

@@ -26,6 +26,7 @@ class EditConcertTest extends TestCase
'state' => 'New state', 'state' => 'New state',
'zip' => '99999', 'zip' => '99999',
'ticket_price' => '72.50', 'ticket_price' => '72.50',
'ticket_quantity' => '10',
], $overrides); ], $overrides);
} }
@@ -169,6 +170,7 @@ class EditConcertTest extends TestCase
'state' => 'Old state', 'state' => 'Old state',
'zip' => '00000', 'zip' => '00000',
'ticket_price' => 2000, 'ticket_price' => 2000,
'ticket_quantity' => 5,
]); ]);
$this->assertFalse($concert->isPublished()); $this->assertFalse($concert->isPublished());
@@ -184,6 +186,7 @@ class EditConcertTest extends TestCase
'state' => 'New state', 'state' => 'New state',
'zip' => '99999', 'zip' => '99999',
'ticket_price' => '72.50', 'ticket_price' => '72.50',
'ticket_quantity' => '10',
]); ]);
$response->assertStatus(404); $response->assertStatus(404);
@@ -198,6 +201,7 @@ class EditConcertTest extends TestCase
$this->assertEquals('Old state', $concert->state); $this->assertEquals('Old state', $concert->state);
$this->assertEquals('00000', $concert->zip); $this->assertEquals('00000', $concert->zip);
$this->assertEquals(2000, $concert->ticket_price); $this->assertEquals(2000, $concert->ticket_price);
$this->assertEquals(5, $concert->ticket_quantity);
}); });
} }
@@ -217,6 +221,7 @@ class EditConcertTest extends TestCase
'state' => 'Old state', 'state' => 'Old state',
'zip' => '00000', 'zip' => '00000',
'ticket_price' => 2000, 'ticket_price' => 2000,
'ticket_quantity' => 5,
]); ]);
$this->assertTrue($concert->isPublished()); $this->assertTrue($concert->isPublished());
@@ -232,6 +237,7 @@ class EditConcertTest extends TestCase
'state' => 'New state', 'state' => 'New state',
'zip' => '99999', 'zip' => '99999',
'ticket_price' => '72.50', 'ticket_price' => '72.50',
'ticket_quantity' => '10',
]); ]);
$response->assertStatus(403); $response->assertStatus(403);
@@ -246,6 +252,7 @@ class EditConcertTest extends TestCase
$this->assertEquals('Old state', $concert->state); $this->assertEquals('Old state', $concert->state);
$this->assertEquals('00000', $concert->zip); $this->assertEquals('00000', $concert->zip);
$this->assertEquals(2000, $concert->ticket_price); $this->assertEquals(2000, $concert->ticket_price);
$this->assertEquals(5, $concert->ticket_quantity);
}); });
} }