class QueryCacheExpiryTest
Public Instance Methods
teardown()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 486 def teardown Task.connection.clear_query_cache end
test_cache_gets_cleared_after_migration()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 490 def test_cache_gets_cleared_after_migration # warm the cache Post.find(1) # change the column definition Post.connection.change_column :posts, :title, :string, limit: 80 assert_nothing_raised { Post.find(1) } # restore the old definition Post.connection.change_column :posts, :title, :string end
test_cache_is_expired_by_habtm_delete()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 556 def test_cache_is_expired_by_habtm_delete assert_called(ActiveRecord::Base.connection, :clear_query_cache, times: 2) do ActiveRecord::Base.cache do p = Post.find(1) assert p.categories.any? p.categories.delete_all end end end
test_cache_is_expired_by_habtm_update()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 546 def test_cache_is_expired_by_habtm_update assert_called(ActiveRecord::Base.connection, :clear_query_cache, times: 2) do ActiveRecord::Base.cache do c = Category.first p = Post.first p.categories << c end end end
test_destroy()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 530 def test_destroy assert_called(Task.connection, :clear_query_cache, times: 2) do Task.cache do Task.find(1).destroy end end end
test_find()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 502 def test_find assert_called(Task.connection, :clear_query_cache) do assert !Task.connection.query_cache_enabled Task.cache do assert Task.connection.query_cache_enabled Task.find(1) Task.uncached do assert !Task.connection.query_cache_enabled Task.find(1) end assert Task.connection.query_cache_enabled end assert !Task.connection.query_cache_enabled end end
test_insert()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 538 def test_insert assert_called(ActiveRecord::Base.connection, :clear_query_cache, times: 2) do Task.cache do Task.create! end end end
test_update()
click to toggle source
# File activerecord/test/cases/query_cache_test.rb, line 520 def test_update assert_called(Task.connection, :clear_query_cache, times: 2) do Task.cache do task = Task.find(1) task.starting = Time.now.utc task.save! end end end