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
Added missing specs for not modifying queues when using AJ test helpers #21904
Added missing specs for not modifying queues when using AJ test helpers #21904
Conversation
r? @schneems (@rails-bot has picked a reviewer for you, use r? to override) |
@@ -308,9 +304,9 @@ def clear_performed_jobs # :nodoc: | |||
|
|||
def enqueued_jobs_size(only: nil) # :nodoc: | |||
if only | |||
enqueued_jobs.select { |job| Array(only).include?(job.fetch(:job)) }.size | |||
enqueued_jobs.count { |job| Array(only).include?(job.fetch(:job)) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this done for a perf optimization or is it critical to the code path? It would be better to not include refactoring to keep the blame clean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a refactoring - probably it will stay like this forever otherwise ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schneems Should I change it back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's minimal enough. In the future though we generally ask for refactoring to be removed. It makes history difficult to reason about.
@seuros looks like you've touched this method before. Thoughts? |
@schneems This change looks good to me. |
Thanks ❤️ |
…queues Added missing specs for not modifying queues when using AJ test helpers
I was wondering why
ensure
statements were needed hererails/activejob/lib/active_job/test_helper.rb
Lines 245 to 247 in e70ec9e
I added missing test for this case and also changed implementation to little more readable (in my opinion at least ;-)) as it's not messing with clearing/restoring the queue