mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
1.6 - Hiding Unpublished Concerts
This commit is contained in:
@@ -9,7 +9,7 @@ class ConcertsController extends Controller
|
|||||||
{
|
{
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$concert = Concert::find($id);
|
$concert = Concert::whereNotNull('published_at')->findOrFail($id);
|
||||||
return view('concerts.show', ['concert' => $concert]);
|
return view('concerts.show', ['concert' => $concert]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class CreateConcertsTable extends Migration
|
|||||||
$table->string('state');
|
$table->string('state');
|
||||||
$table->string('zip');
|
$table->string('zip');
|
||||||
$table->text('additional_information');
|
$table->text('additional_information');
|
||||||
|
$table->datetime('published_at')->nullable();
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ class ViewConcertListingTest extends TestCase
|
|||||||
/** @test */
|
/** @test */
|
||||||
function user_can_view_a_concert_listing()
|
function user_can_view_a_concert_listing()
|
||||||
{
|
{
|
||||||
// Arrange
|
|
||||||
// Create a concert
|
|
||||||
$concert = Concert::create([
|
$concert = Concert::create([
|
||||||
'title' => 'The Red Chord',
|
'title' => 'The Red Chord',
|
||||||
'subtitle' => 'with Animosity and Lethargy',
|
'subtitle' => 'with Animosity and Lethargy',
|
||||||
@@ -28,12 +26,8 @@ class ViewConcertListingTest extends TestCase
|
|||||||
'additional_information' => 'For tickets, call (555) 555-5555.',
|
'additional_information' => 'For tickets, call (555) 555-5555.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Act
|
|
||||||
// View the concert listing
|
|
||||||
$this->visit('/concerts/'.$concert->id);
|
$this->visit('/concerts/'.$concert->id);
|
||||||
|
|
||||||
// Assert
|
|
||||||
// See the concert details
|
|
||||||
$this->see('The Red Chord');
|
$this->see('The Red Chord');
|
||||||
$this->see('with Animosity and Lethargy');
|
$this->see('with Animosity and Lethargy');
|
||||||
$this->see('December 13, 2016');
|
$this->see('December 13, 2016');
|
||||||
@@ -44,4 +38,16 @@ class ViewConcertListingTest extends TestCase
|
|||||||
$this->see('Laraville, ON 17916');
|
$this->see('Laraville, ON 17916');
|
||||||
$this->see('For tickets, call (555) 555-5555.');
|
$this->see('For tickets, call (555) 555-5555.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
function user_cannot_view_unpublished_concert_listings()
|
||||||
|
{
|
||||||
|
$concert = factory(Concert::class)->create([
|
||||||
|
'published_at' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->get('/concerts/'.$concert->id);
|
||||||
|
|
||||||
|
$this->assertResponseStatus(404);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user