1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/generators/multi_db_generator_test.rb
eileencodes 770e12fddc
Move multi-db config options to middleware
This doesn't really make sense in the production config especially since
you probably want to use it in all of your environments. This change
moves the database and shard swapping configuration options into a
generator. The generator can be run like this:

```
bin/rails g active_record:automatic_swapping
```

This change allows apps to add additional configuration for multiple
databases all in one place.

The config options can still be defined in the environment config if
desired but this cleans up the default config for new applications
especially since new applications probably don't need multiple
databases.
2021-12-08 13:01:04 -05:00

18 lines
611 B
Ruby

# frozen_string_literal: true
require "generators/generators_test_helper"
require "rails/generators/active_record/multi_db/multi_db_generator"
class MultiDbGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
tests ActiveRecord::Generators::MultiDbGenerator
def test_multi_db_skeleton_is_created
run_generator
assert_file "config/initializers/multi_db.rb" do |record|
assert_match(/Multi-db Configuration/, record)
assert_match(/config.active_record.database_resolver/, record)
assert_match(/config.active_record.shard_resolver/, record)
end
end
end