diff options
author | Yasuo Honda <yasuo.honda@gmail.com> | 2017-01-31 14:36:15 +0000 |
---|---|---|
committer | Yasuo Honda <yasuo.honda@gmail.com> | 2017-01-31 16:20:21 +0000 |
commit | 1320fa6efd986832bf798792e83917684394dd99 (patch) | |
tree | 9313f7f60f92a275b98728e93de25cb8eae07605 | |
parent | 1fc995577f44e748bbcaf25c35fd24bb56afc63e (diff) | |
download | rails-1320fa6efd986832bf798792e83917684394dd99.tar.gz rails-1320fa6efd986832bf798792e83917684394dd99.tar.bz2 rails-1320fa6efd986832bf798792e83917684394dd99.zip |
Use temporary connection pool for sqlite3_mem adapter
Fixes #27826
Refer https://github.com/rails/rails/commit/f7b317175430a2d9300d9c4acfc1f34f4fdb2fbc
-rw-r--r-- | activerecord/test/cases/query_cache_test.rb | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index 04e48e201e..d8cf235000 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -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 |