未验证 提交 5118a3b8 编写于 作者: J Jon Moss

Add explicit testing for `uncached` vs. `cached`

There are a ton of middleware related tests in this file, and it seems
like `cached vs. `uncached` is being neglected. Added in a test to
confirm the expected behavior.
上级 7ad8093b
......@@ -190,6 +190,27 @@ def test_cache_is_not_available_when_using_a_not_connected_connection
Task.connection_specification_name = spec_name
end
def test_query_cache_executes_new_queries_within_block
ActiveRecord::Base.connection.enable_query_cache!
# Warm up the cache by running the query
assert_queries(1) do
assert_equal 0, Post.where(title: 'test').to_a.count
end
# Check that if the same query is run again, no queries are executed
assert_queries(0) do
assert_equal 0, Post.where(title: 'test').to_a.count
end
ActiveRecord::Base.connection.uncached do
# Check that new query is executed, avoiding the cache
assert_queries(1) do
assert_equal 0, Post.where(title: 'test').to_a.count
end
end
end
def test_query_cache_doesnt_leak_cached_results_of_rolled_back_queries
ActiveRecord::Base.connection.enable_query_cache!
post = Post.first
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册