Skip to content

Commit 60622b0

Browse files
committed
Fix incomplete schedule scope bug
1 parent abcbadf commit 60622b0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/Models/Schedule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function formattedMessage(): string
5353
*/
5454
public function scopeIncomplete(Builder $query): Builder
5555
{
56-
return $query->whereIn('status', [ScheduleStatusEnum::incomplete()])
56+
return $query->whereIn('status', ScheduleStatusEnum::incomplete())
5757
->whereNull('completed_at');
5858
}
5959

tests/Unit/Models/ScheduleTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Cachet\Enums\ScheduleStatusEnum;
34
use Cachet\Models\Schedule;
45
use Cachet\Models\ScheduleComponent;
56

@@ -15,6 +16,21 @@
1516
->components->toHaveCount(2);
1617
});
1718

19+
it('can get incomplete schedules', function () {
20+
[$scheduleA, ] = Schedule::factory()
21+
->count(3)
22+
->sequence(
23+
['status' => ScheduleStatusEnum::in_progress],
24+
['status' => ScheduleStatusEnum::upcoming],
25+
['status' => ScheduleStatusEnum::complete],
26+
)
27+
->create();
28+
29+
expect(Schedule::query()->incomplete()->get())
30+
->toHaveCount(2)
31+
->first()->id->toBe($scheduleA->id);
32+
});
33+
1834
it('can get in-progress schedules', function () {
1935
$schedule = Schedule::factory()->inThePast()->create();
2036
$scheduleInProgress = Schedule::factory()->inProgress()->create();

0 commit comments

Comments
 (0)