提交 032fe348 编写于 作者: S Sean Griffin 提交者: GitHub

Merge pull request #25460 from maclover7/jm-uncached

Add explicit testing for `uncached` vs. `cached`
......@@ -275,6 +275,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.
先完成此消息的编辑!
想要评论请 注册