New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the ability to override the queue adapter used by jobs under test #25367

Merged
merged 1 commit into from Jun 11, 2016

Conversation

Projects
None yet
5 participants
@stephenminded
Contributor

stephenminded commented Jun 11, 2016

Our Rails application uses a custom background job implementation from before ActiveJob. We're trying to migrate our code to use ActiveJob and part of that is to update our test suite to use the ActiveJob test helpers. In order to do that, we wrote a test queue adapter which wraps our background job queue adapter and conforms to the ActiveJob::QueueAdapter::TestAdapter interface in order to make the active job assertions work. Currently, ActiveJob::TestHelper provides no way to override the queue adapter used in tests, so we're stuck maintaining a patch that provides this behaviour.

This PR adds a method called queue_adapter_for_test to ActiveJob::TestHelper. The new method is expected to provide an instance of the queue adapter to be used for jobs under test. It maintains the current behaviour by defaulting to an instance of ActiveJob::QueueAdapter::TestAdapter.

Tests that include ActiveJob::TestHelper or extend from ActiveJob::TestCase can now provide a custom queue adapter by overriding queue_adapter_for_test in their test class.

@rafaelfranca @byroot

Provide the ability to override the queue adapter used by jobs under
test.

This PR adds a method called `queue_adapter_for_test` to
`ActiveJob::TestHelper`. This method is expected to provide the queue
adapter to be used for jobs under test. It maintains the current
behaviour by defaulting to an instance of
`ActiveJob::QueueAdapter::TestAdapter`. Tests that include
`ActiveJob::TestHelper` or extend from `ActiveJob::TestCase` can provide
a custom queue adapter by overriding `queue_adapter_for_test` in their
class.
@rails-bot

This comment has been minimized.

rails-bot commented Jun 11, 2016

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @senny (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@maclover7 maclover7 added the activejob label Jun 11, 2016

@rafaelfranca rafaelfranca merged commit 7f6af4b into rails:master Jun 11, 2016

rafaelfranca added a commit that referenced this pull request Jun 11, 2016

Merge pull request #25367 from stephenminded/active_job_test_helper_c…
…ustom_queue_adapter

Provide the ability to override the queue adapter used by jobs under test
@rafaelfranca

This comment has been minimized.

Member

rafaelfranca commented Jun 11, 2016

Backported in 47a6191

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment