mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-08 17:50:42 +00:00
(add authorization tests for publishing concerts)
This commit is contained in:
@@ -48,4 +48,53 @@ class PublishConcertTest extends TestCase
|
||||
$response->assertStatus(422);
|
||||
$this->assertEquals(3, $concert->fresh()->ticketsRemaining());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function a_promoter_cannot_publish_other_concerts()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$otherUser = factory(User::class)->create();
|
||||
$concert = factory(Concert::class)->states('unpublished')->create([
|
||||
'user_id' => $otherUser->id,
|
||||
'ticket_quantity' => 3,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->post('/backstage/published-concerts', [
|
||||
'concert_id' => $concert->id,
|
||||
]);
|
||||
|
||||
$response->assertStatus(404);
|
||||
$concert = $concert->fresh();
|
||||
$this->assertFalse($concert->isPublished());
|
||||
$this->assertEquals(0, $concert->ticketsRemaining());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function a_guest_cannot_publish_concerts()
|
||||
{
|
||||
$concert = factory(Concert::class)->states('unpublished')->create([
|
||||
'ticket_quantity' => 3,
|
||||
]);
|
||||
|
||||
$response = $this->post('/backstage/published-concerts', [
|
||||
'concert_id' => $concert->id,
|
||||
]);
|
||||
|
||||
$response->assertRedirect('/login');
|
||||
$concert = $concert->fresh();
|
||||
$this->assertFalse($concert->isPublished());
|
||||
$this->assertEquals(0, $concert->ticketsRemaining());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function concerts_that_do_not_exist_cannot_be_published()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$response = $this->actingAs($user)->post('/backstage/published-concerts', [
|
||||
'concert_id' => 999,
|
||||
]);
|
||||
|
||||
$response->assertStatus(404);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user