Skip to content

Commit 636c056

Browse files
committed
Fix unresolved incident scope
1 parent bb39dc1 commit 636c056

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/Models/Incident.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public function scopeStatus(Builder $query, IncidentStatusEnum $status): Builder
8181
return $query->where('status', $status);
8282
}
8383

84-
public function scopeUnresolved(Builder $builder): Builder
84+
public function scopeUnresolved(Builder $query): Builder
8585
{
86-
return $this->whereIn('status', IncidentStatusEnum::unresolved());
86+
return $query->whereIn('status', IncidentStatusEnum::unresolved());
8787
}
8888

8989
/**

tests/Unit/Models/IncidentTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,15 @@
3333
expect(Incident::query()->count())->toBe(2)
3434
->and(Incident::query()->stickied()->count())->toBe(1);
3535
});
36+
37+
it('can scope to unresolved incidents', function () {
38+
Incident::factory()->sequence(
39+
['status' => IncidentStatusEnum::investigating],
40+
['status' => IncidentStatusEnum::identified],
41+
['status' => IncidentStatusEnum::watching],
42+
['status' => IncidentStatusEnum::fixed],
43+
)->count(4)->create();
44+
45+
expect(Incident::query()->count())->toBe(4)
46+
->and(Incident::query()->unresolved()->count())->toBe(3);
47+
});

0 commit comments

Comments
 (0)