Ian Burry

Joined

750 Experience
0 Lessons Completed
1 Question Solved

Activity

Well, I learned about Parallel Testing today, a new "feature" of Rails 6. Kinda cool, but probably shouldn't be a default of newly created applications.

It also means that you need to give your mysql user privileges on databases that match a pattern:

grant all privileges on `sample_app_test-%`.* to 'my_user'@'%';

rails 6.0
minitest 5.1
mysql2 gem

I'm having (what seems to me) a rather peculiar problem running rails test right from the get-go. All the correct databases exist, the rails user has what should be all the required privileges, and I've run db:migrate. Rather than using the app test database, it will try to create numbered versions of it and use those. The error I get is like:

Mysql2::Error::ConnectionError: Access denied for user 'rails_remote'@'%' to database 'sample_app_test-3'

Naturally, this fails, because the rails user does not have the CREATE privilege. Even with it, the rails user does not have any privileges on the newly created databases, so it fails again.

How do I get rails to use the existing test database rather than trying to create its own?

ETA: It seems to be associated with the following line in test_helper.rb. Comment it out and things seem to work as expected.

parallelize(workers: :number_of_processors)
logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.