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

Clarification of multi-db capabilities #17

Open
sriedel opened this issue Sep 8, 2021 · 0 comments
Open

Clarification of multi-db capabilities #17

sriedel opened this issue Sep 8, 2021 · 0 comments

Comments

@sriedel
Copy link

sriedel commented Sep 8, 2021

The README states

#db defaults to the default Mongoid database, but can be specified manually in a few ways:

querying DatabaseCleaner[:mongoid].db returns :default, however I do not have a database called default, yet DatabaseCleaner works as expected. I do have a Mongoid client configured via mongoid.yml called default, though.

When attempting to tell DatabaseCleaner to clean database that is referenced via a differently named client, I need to supply the other clients name to DatabaseCleaner[:mongoid].db instead of the actual databases name for things to work as expected. Specifying DatabaseCleaner[:mongoid, db: :actual_database_name].start and ...clean does not work.

So it seems that the #db method is a misnomer and instead accesses Mongoid.clients[DatabaseCleaner[:mongoid].db] to resolve the actual clients/databases to clean (deduced from observed behavior, I didn't check in the code).

Could you please clarify what the actual configuration should be? Also, is it possible to have DatabaseCleaner handle multiple databases/clients/sessions at once, and if so, how would that be configured?

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

No branches or pull requests

1 participant