142 - Optional Files and the Null Object Pattern

This commit is contained in:
Adam Wathan
2017-09-29 15:24:47 -04:00
parent e18ba35efd
commit 57e1ce97a7
3 changed files with 33 additions and 1 deletions

View File

@@ -440,4 +440,24 @@ class AddConcertTest extends TestCase
$response->assertSessionHasErrors('poster_image');
$this->assertEquals(0, Concert::count());
}
/** @test */
function poster_image_is_optional()
{
$this->disableExceptionHandling();
$user = factory(User::class)->create();
$response = $this->actingAs($user)->post('/backstage/concerts', $this->validParams([
'poster_image' => null,
]));
tap(Concert::first(), function ($concert) use ($response, $user) {
$response->assertRedirect('/backstage/concerts');
$this->assertTrue($concert->user->is($user));
$this->assertNull($concert->poster_image_path);
});
}
}