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

Added missing specs for not modifying queues when using AJ test helpers #21904

Merged

Conversation

morgoth
Copy link
Member

@morgoth morgoth commented Oct 7, 2015

I was wondering why ensure statements were needed here

ensure
queue_adapter.enqueued_jobs = original_enqueued_jobs + enqueued_jobs
end
as when I removed them, tests were still passing.

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

@rails-bot
Copy link

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)) }
Copy link
Member

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.

Copy link
Member Author

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 ;-)

Copy link
Member Author

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?

Copy link
Member

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.

@schneems
Copy link
Member

schneems commented Oct 7, 2015

@seuros looks like you've touched this method before. Thoughts?

@seuros
Copy link
Member

seuros commented Oct 7, 2015

@schneems This change looks good to me.

@schneems
Copy link
Member

schneems commented Oct 7, 2015

Thanks ❤️

schneems added a commit that referenced this pull request Oct 7, 2015
…queues

Added missing specs for not modifying queues when using AJ test helpers
@schneems schneems merged commit 5ddf6df into rails:master Oct 7, 2015
@morgoth morgoth deleted the missing-test-for-not-modifing-queues branch October 7, 2015 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants