Skip to content
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

Add at option to perform_enqueued_jobs test helper #36864

Merged

Conversation

seejohnrun
Copy link
Member

@seejohnrun seejohnrun commented Aug 6, 2019

Summary

Currently, the perform_enqueued_jobs helper will also immediately
perform jobs that are scheduled via set(wait:) to run in the future.
This PR adds a new argument to perform_enqueued_jobs to make it
only run jobs scheduled at or before the passed in Time. This allows
testing the side effects of immediate job execution separate of jobs
delayed in the future.

@rails-bot rails-bot bot added the activejob label Aug 6, 2019
@eileencodes eileencodes added this to the 6.1.0 milestone Aug 6, 2019
Currently, the `perform_enqueued_jobs` helpers will also immediately
perform jobs that are scheduled via `set(wait:)` to run in the future.
This commit adds a new argument to `perform_enqueued_jobs` to make it
only run jobs scheduled at or before the passed in `Time`. This allows
testing the side effects of immediate job execution separate of jobs
delayed in the future.
@seejohnrun seejohnrun force-pushed the activejob-test-helper-set-wait branch from 549c21c to 647317d Compare August 6, 2019 14:32
@eileencodes eileencodes merged commit eb4faa1 into rails:master Aug 6, 2019
@seejohnrun seejohnrun deleted the activejob-test-helper-set-wait branch August 6, 2019 20:33
@@ -117,7 +117,7 @@ def queue_adapter_for_test
# HelloJob.perform_later('elfassy')
# end
# end
def assert_enqueued_jobs(number, only: nil, except: nil, queue: nil)
def assert_enqueued_jobs(number, only: nil, except: nil, queue: nil, at: at)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes a warning:

activejob/lib/active_job/test_helper.rb:120: warning: circular argument reference - at

Why is this unused argument needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Addressed in #36881

@bogdanvlviv
Copy link
Contributor

We should add a changelog entry in activejob/CHANGELOG.md file about this feature.

seejohnrun added a commit to seejohnrun/rails that referenced this pull request Aug 7, 2019
In rails#36864 we made a change to an ActiveJob test helper to add a new
parameter for testing jobs delayed into the future.

This commit adds a CHANGELOG entry for that change as well as fixing a
circular argument error.
@seejohnrun
Copy link
Member Author

@bogdanvlviv added in #36881! Thank you

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

Successfully merging this pull request may close these issues.

None yet

4 participants