1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use temporary connection pool for sqlite3_mem adapter

Fixes #27826
Refer f7b3171754
This commit is contained in:
Yasuo Honda 2017-01-31 14:36:15 +00:00
parent 1fc995577f
commit 1320fa6efd

View file

@ -286,19 +286,30 @@ class QueryCacheTest < ActiveRecord::TestCase
end
def test_cache_is_not_available_when_using_a_not_connected_connection
spec_name = Task.connection_specification_name
conf = ActiveRecord::Base.configurations["arunit"].merge("name" => "test2")
ActiveRecord::Base.connection_handler.establish_connection(conf)
Task.connection_specification_name = "test2"
refute Task.connected?
with_temporary_connection_pool do
spec_name = Task.connection_specification_name
conf = ActiveRecord::Base.configurations["arunit"].merge("name" => "test2")
ActiveRecord::Base.connection_handler.establish_connection(conf)
Task.connection_specification_name = "test2"
refute Task.connected?
Task.cache do
Task.connection # warmup postgresql connection setup queries
assert_queries(2) { Task.find(1); Task.find(1) }
Task.cache do
begin
if in_memory_db?
Task.connection.create_table :tasks do |t|
t.datetime :starting
t.datetime :ending
end
ActiveRecord::FixtureSet.create_fixtures(self.class.fixture_path, ["tasks"], {}, ActiveRecord::Base)
end
Task.connection # warmup postgresql connection setup queries
assert_queries(2) { Task.find(1); Task.find(1) }
ensure
ActiveRecord::Base.connection_handler.remove_connection(Task.connection_specification_name)
Task.connection_specification_name = spec_name
end
end
end
ensure
ActiveRecord::Base.connection_handler.remove_connection(Task.connection_specification_name)
Task.connection_specification_name = spec_name
end
def test_query_cache_executes_new_queries_within_block