Merge pull request #3105 from nstapelbroek/feature/fix-incident-update-on-untracked-incident

Allow updating incidents when the incident has no associated user
This commit is contained in:
James Brooks 2018-06-28 08:43:39 +01:00 committed by GitHub
commit 91d41c4799
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -120,7 +120,7 @@ class Incident extends Model implements HasPresenter
* @var string[]
*/
public $rules = [
'user_id' => 'required|int',
'user_id' => 'nullable|int',
'component_id' => 'nullable|int',
'name' => 'required|string',
'status' => 'required|int',

View File

@ -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()
{
$this->beUser();