aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorutilum <oz@utilum.com>2018-07-21 01:30:15 +0300
committerutilum <oz@utilum.com>2018-07-22 08:38:11 +0300
commita94d6ae81fea43d075ab31d53c54d3065c57d233 (patch)
tree489c8c17fd55498cc2b00290b932af7894472854 /activerecord/test
parentd3ba91315852d27e95a935359f4ad752c27d02d3 (diff)
downloadrails-a94d6ae81fea43d075ab31d53c54d3065c57d233.tar.gz
rails-a94d6ae81fea43d075ab31d53c54d3065c57d233.tar.bz2
rails-a94d6ae81fea43d075ab31d53c54d3065c57d233.zip
Fix Mocha replacement that slipped out of #33337
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/tasks/database_tasks_test.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/activerecord/test/cases/tasks/database_tasks_test.rb b/activerecord/test/cases/tasks/database_tasks_test.rb
index 1f79f1a630..b9cc08c446 100644
--- a/activerecord/test/cases/tasks/database_tasks_test.rb
+++ b/activerecord/test/cases/tasks/database_tasks_test.rb
@@ -143,9 +143,6 @@ module ActiveRecord
def setup
@configurations = { "development" => { "database" => "my-db" } }
- # To refrain from connecting to a newly created empty DB in sqlite3_mem tests
- ActiveRecord::Base.connection_handler.stubs(:establish_connection)
-
$stdout, @original_stdout = StringIO.new, $stdout
$stderr, @original_stderr = StringIO.new, $stderr
end
@@ -157,7 +154,7 @@ module ActiveRecord
def test_ignores_configurations_without_databases
@configurations["development"].merge!("database" => nil)
- with_stubbed_configurations do
+ with_stubbed_configurations_establish_connection do
assert_not_called(ActiveRecord::Tasks::DatabaseTasks, :create) do
ActiveRecord::Tasks::DatabaseTasks.create_all
end
@@ -167,7 +164,7 @@ module ActiveRecord
def test_ignores_remote_databases
@configurations["development"].merge!("host" => "my.server.tld")
- with_stubbed_configurations do
+ with_stubbed_configurations_establish_connection do
assert_not_called(ActiveRecord::Tasks::DatabaseTasks, :create) do
ActiveRecord::Tasks::DatabaseTasks.create_all
end
@@ -177,7 +174,7 @@ module ActiveRecord
def test_warning_for_remote_databases
@configurations["development"].merge!("host" => "my.server.tld")
- with_stubbed_configurations do
+ with_stubbed_configurations_establish_connection do
ActiveRecord::Tasks::DatabaseTasks.create_all
assert_match "This task only modifies local databases. my-db is on a remote host.",
@@ -188,7 +185,7 @@ module ActiveRecord
def test_creates_configurations_with_local_ip
@configurations["development"].merge!("host" => "127.0.0.1")
- with_stubbed_configurations do
+ with_stubbed_configurations_establish_connection do
assert_called(ActiveRecord::Tasks::DatabaseTasks, :create) do
ActiveRecord::Tasks::DatabaseTasks.create_all
end
@@ -198,7 +195,7 @@ module ActiveRecord
def test_creates_configurations_with_local_host
@configurations["development"].merge!("host" => "localhost")
- with_stubbed_configurations do
+ with_stubbed_configurations_establish_connection do
assert_called(ActiveRecord::Tasks::DatabaseTasks, :create) do
ActiveRecord::Tasks::DatabaseTasks.create_all
end
@@ -208,7 +205,7 @@ module ActiveRecord
def test_creates_configurations_with_blank_hosts
@configurations["development"].merge!("host" => nil)
- with_stubbed_configurations do
+ with_stubbed_configurations_establish_connection do
assert_called(ActiveRecord::Tasks::DatabaseTasks, :create) do
ActiveRecord::Tasks::DatabaseTasks.create_all
end
@@ -217,9 +214,16 @@ module ActiveRecord
private
- def with_stubbed_configurations
+ def with_stubbed_configurations_establish_connection
ActiveRecord::Base.stub(:configurations, @configurations) do
- yield
+ # To refrain from connecting to a newly created empty DB in
+ # sqlite3_mem tests
+ ActiveRecord::Base.connection_handler.stub(
+ :establish_connection,
+ nil
+ ) do
+ yield
+ end
end
end
end