Closed tachyons closed 5 years ago
Hey, I tried this PR on my project but it deletes the development database at the end of tests.
It happens when rails 6 new feature is used: parallelize(workers: :number_of_processors)
with apartment gem.
I tried to reproduce on a brand new rails project without apartment gem and I couldn't.
Interesting. I could reproduce the issue here https://github.com/tachyons/rails6_apartment. Yet to investigate the cause
FYI,
I wanted to help figure this out to help move the rails 6 updates further. Unfortunately I was not able to reproduce this issue with your repo at https://github.com/tachyons/rails6_apartment or with my own codebase.
Just run rails test on above repo, it will fail
Sorry, you are correct. I misread. I thought the issue was with the development db was being dropped. I'll experiment some more.
Here's an example of how I was able to get parallel tests working with apartment on a fresh Rails 6 app: https://github.com/bdtomlin/my_apartment.
I added the following to my test_helper.rb...
class ActiveSupport::TestCase
parallelize_setup do
Apartment::Tenant.drop('www') rescue nil
Apartment::Tenant.create('www')
Apartment::Tenant.switch! 'www'
end
parallelize_teardown do
Apartment::Tenant.drop('www') rescue nil
Apartment::Tenant.reset
end
# Run tests in parallel with specified workers
parallelize(workers: :number_of_processors)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
I know there are lot's of different ways that someone may have their app set up, but this gives the basic principles of how to make it work.
The basic premise is based on this wiki article: https://github.com/influitive/apartment/wiki/Testing-Your-Application
If something like this is a sufficient solution, maybe we can add it to the README or the wiki.
This PR is to Add Rails 6 in test matrix and make it 💚 . Rails 6 specific enhancements are not part of this PR
Fixes #598