提交 ae01c921 编写于 作者: E eileencodes

Revert "Merge pull request #32075 from eileencodes/delete-default-configuration"

This reverts commit 16f279eb, reversing
changes made to 6c6a30a7.

The config can be named anything, not just default (although all
generated apps will be named default). We can't just delete configs that
don't have a database because that will break three-tier configs. Oh
well.
上级 edb61ca8
......@@ -315,12 +315,16 @@ def each_current_configuration(environment)
environments << "test" if environment == "development"
ActiveRecord::Base.configurations.slice(*environments).each do |configuration_environment, configuration|
next unless configuration["database"]
yield configuration, configuration_environment
end
end
def each_local_configuration
ActiveRecord::Base.configurations.each_value do |configuration|
next unless configuration["database"]
if local_database?(configuration)
yield configuration
else
......
......@@ -124,6 +124,14 @@ def setup
ActiveRecord::Base.connection_handler.stubs(:establish_connection)
end
def test_ignores_configurations_without_databases
@configurations["development"].merge!("database" => nil)
ActiveRecord::Tasks::DatabaseTasks.expects(:create).never
ActiveRecord::Tasks::DatabaseTasks.create_all
end
def test_ignores_remote_databases
@configurations["development"].merge!("host" => "my.server.tld")
$stderr.stubs(:puts).returns(nil)
......@@ -242,6 +250,14 @@ def setup
ActiveRecord::Base.stubs(:configurations).returns(@configurations)
end
def test_ignores_configurations_without_databases
@configurations[:development].merge!("database" => nil)
ActiveRecord::Tasks::DatabaseTasks.expects(:drop).never
ActiveRecord::Tasks::DatabaseTasks.drop_all
end
def test_ignores_remote_databases
@configurations[:development].merge!("host" => "my.server.tld")
$stderr.stubs(:puts).returns(nil)
......
......@@ -179,7 +179,6 @@ def database_configuration
values.reverse_merge!(shared)
end
end
loaded_yaml.delete("default")
Hash.new(shared).merge(loaded_yaml)
elsif ENV["DATABASE_URL"]
# Value from ENV['DATABASE_URL'] is set to default database connection
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册