diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-01-31 16:01:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-31 16:01:36 -0500 |
commit | a57b5292b0987c62d8567b253c9b54dc84b560d6 (patch) | |
tree | 9fbdfc25ca95fd6d023a7ed10452a9293166911b /activerecord/test | |
parent | 3f2b7d60a52ffb2ad2d4fcf889c06b631db1946b (diff) | |
parent | 5213643ed9e17d0e90789bb6492e0ba87fe61788 (diff) | |
download | rails-a57b5292b0987c62d8567b253c9b54dc84b560d6.tar.gz rails-a57b5292b0987c62d8567b253c9b54dc84b560d6.tar.bz2 rails-a57b5292b0987c62d8567b253c9b54dc84b560d6.zip |
Merge pull request #27859 from yahonda/diag27826
Use temporary connection pool for sqlite3_mem adapter
Diffstat (limited to 'activerecord/test')
-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 |