Allow updating incidents when the incident has no associated user
This commit is contained in:
committed by
Nico Stapelbroek
parent
3e3763722b
commit
253d9ec445
@@ -120,7 +120,7 @@ class Incident extends Model implements HasPresenter
|
|||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $rules = [
|
public $rules = [
|
||||||
'user_id' => 'required|int',
|
'user_id' => 'nullable|int',
|
||||||
'component_id' => 'nullable|int',
|
'component_id' => 'nullable|int',
|
||||||
'name' => 'required|string',
|
'name' => 'required|string',
|
||||||
'status' => 'required|int',
|
'status' => 'required|int',
|
||||||
|
|||||||
@@ -179,6 +179,23 @@ class IncidentTest extends AbstractApiTestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_can_update_incident_when_no_user_is_associated()
|
||||||
|
{
|
||||||
|
$incident = factory(Incident::class)->create(['user_id' => null]);
|
||||||
|
$this->beUser();
|
||||||
|
$this->expectsEvents(IncidentWasUpdatedEvent::class);
|
||||||
|
|
||||||
|
$response = $this->json('PUT', '/api/v1/incidents/1', [
|
||||||
|
'name' => 'Updated incident name',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
$response->assertJsonFragment([
|
||||||
|
'name' => 'Updated incident name',
|
||||||
|
'user_id' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_can_delete_incident()
|
public function test_can_delete_incident()
|
||||||
{
|
{
|
||||||
$this->beUser();
|
$this->beUser();
|
||||||
|
|||||||
Reference in New Issue
Block a user