Make perform_enqueued_jobs
compatible with all Active Job adapters
#48599
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Background
#37270 describes a common Active Job issue where if you try to set an adapter other than
:test
as your adapter in a test environment, you get some confusing results.The most popular workaround on the issue is to add this to a setup block:
This solves some issues, but causes others. bensheldon/good_job#846 is an example of an issue it causes. If you call
assert_emails
in an integration test, it will crash here because only the test adapter definesperform_enqueued_jobs
.I think we should fix the issue of Active Job adapters being inconsistent across tests fully, and #48585 is my work in progress for that. But I wanted to extract this fix from that PR since I think it's useful in isolation.
Detail
With this PR,
perform_enqueued_jobs
will yield if a block is given but the test adapter is not being used. This is the minimum required to make that method compatible with any adapter.Additional information
ref: bensheldon/good_job#846, #37270
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]