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

ActiveJob::QueueAdapters::TestAdapter is now a singleton #19052

Merged
merged 1 commit into from
Feb 24, 2015

Conversation

tamird
Copy link
Contributor

@tamird tamird commented Feb 23, 2015

Since ActiveJob::TestHelper globally sets
ActiveJob::Base.queue_adapter on setup, there is no benefit in
instantiating a new TestAdapter per tests. The original rationale was
to allow parallel tests to run without interference, but since they'd
all mutate the global ActiveJob::Base.queue_adapter, that was never
realized.

@cristianbica @jeremy @dhh

@rafaelfranca
Copy link
Member

Is there any advantage of using a singleton? I know our current setup doesn't allow parallel test but in future we may change it. If we change it to a singleton now it will just make harder to implement parallel support, so unless we have a good reason to not use instances I'd like to keep it.

@@ -17,8 +17,6 @@ module ClassMethods
def queue_adapter=(name_or_adapter)
@@queue_adapter = \
case name_or_adapter
when :test
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rafaelfranca the only advantage is that it removes this special handling, which is a weird snowflake.

I believe this doesn't really get us further away from parallel tests - if #16992 is merged, each test will be able to create its own anonymous subclass, which might actually be pretty simple to do. What do you think?

@rafaelfranca
Copy link
Member

This needs a rebase

Since `ActiveJob::TestHelper` globally sets
`ActiveJob::Base.queue_adapter` on setup, there is no benefit in
instantiating a new `TestAdapter` per tests. The original rationale was
to allow parallel tests to run without interference, but since they'd
all mutate the global `ActiveJob::Base.queue_adapter`, that was never
realized.
@tamird
Copy link
Contributor Author

tamird commented Feb 24, 2015

@rafaelfranca resolved

rafaelfranca added a commit that referenced this pull request Feb 24, 2015
`ActiveJob::QueueAdapters::TestAdapter` is now a singleton
@rafaelfranca rafaelfranca merged commit 2948404 into rails:master Feb 24, 2015
@tamird tamird deleted the testing-singleton branch February 24, 2015 02:14
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

2 participants