Mongoid multi tenant using multiple database
Add this line to your application's Gemfile:
gem 'manganese', github: 'marcosanson/manganese'
TODO: Working progress...
Manganese provides the following two testing modes:
-
A test
fake
mode that always use only one database -
A
live
mode that create a database for each tenant
require 'manganese/testing'
RSpec.configure do |config|
config.before(:each) do |example|
if example.metadata[:manganese] == :fake
Manganese::Testing.fake!
elsif example.metadata[:manganese] == :live
Manganese::Testing.live!
elsif example.metadata[:type] == :acceptance
Manganese::Testing.live!
else
Manganese::Testing.fake!
end
end
config.after(:each) do
Manganese.reset_tenant!
end
end
- Fork it ( https://github.com/[my-github-username]/manganese/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request