ActiveJob was introduced so that all Rails apps have the adequate queuing infrastructure in place. It is not dependent on the actual queue adapter that is selected, allowing for easy switching between queue infrastructures in the future.
It means that queue configurations become the responsibility of the queue adapter and not ActiveJob itself. Hence, ActiveJob allows for priority levels to be set if the queue adapter supports it.
While this works great in building queueing systems, it often hinders writing tests for ActiveJob. However, the Rails team is working towards unifying that!
Before
When writing ActiveJob tests,
only minimal configurations were testable,
such as the time to queue
and queue name
.
It was not possible to write tests for jobs
that make use of the priority
parameter.
It would throw a parameter priority not found
error.
After
With Rails 7, we now can test with the priority parameter for both assert_enqueued_with and assert_performed_with test helper methods.