diff --git a/src/Listeners/StoreTagsForFailedJob.php b/src/Listeners/StoreTagsForFailedJob.php index dfd0d2f6..45f7898f 100644 --- a/src/Listeners/StoreTagsForFailedJob.php +++ b/src/Listeners/StoreTagsForFailedJob.php @@ -38,7 +38,7 @@ public function handle(JobFailed $event) })->all(); $this->tags->addTemporary( - 2880, $event->payload->id(), $tags + config('horizon.trim.failed', 2880), $event->payload->id(), $tags ); } } diff --git a/tests/Feature/Listeners/StoreTagsForFailedTest.php b/tests/Feature/Listeners/StoreTagsForFailedTest.php new file mode 100644 index 00000000..62affb91 --- /dev/null +++ b/tests/Feature/Listeners/StoreTagsForFailedTest.php @@ -0,0 +1,49 @@ +set('horizon.trim.failed', 120); + + $tagRepository = m::mock(TagRepository::class); + + $tagRepository->shouldReceive('addTemporary')->once()->with(120, '1', ['failed:foobar'])->andReturn([]); + + $this->instance(TagRepository::class, $tagRepository); + + $this->app->make(Dispatcher::class)->dispatch(new JobFailed( + new Exception('job failed'), new FailedJob(), '{"id":"1","displayName":"displayName","tags":["foobar"]}' + )); + } +} + +class FailedJob extends Job +{ + public function getJobId() + { + return '1'; + } + + public function getRawBody() + { + return ''; + } +}