mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
1581cab9ff
This commit passes the template format to the digestor in order to come up with a key. Before this commit, the digestor would depend on the side effect of the template renderer setting the rendered_format on the lookup context. I would like to remove that mutation, so I've changed this to pass the template format in to the digestor. I've introduced a new instance variable that will be alive during a template render. When the template is being rendered, it pushes the current template on to a stack, setting `@current_template` to the template currently being rendered. When the cache helper asks the digestor for a key, it uses the format of the template currently on the stack.
25 lines
808 B
Ruby
25 lines
808 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "active_record_unit"
|
|
|
|
class RelationCacheTest < ActionView::TestCase
|
|
tests ActionView::Helpers::CacheHelper
|
|
|
|
def setup
|
|
super
|
|
view_paths = ActionController::Base.view_paths
|
|
lookup_context = ActionView::LookupContext.new(view_paths, {}, ["test"])
|
|
@view_renderer = ActionView::Renderer.new(lookup_context)
|
|
@virtual_path = "path"
|
|
@current_template = lookup_context.find "test/hello_world"
|
|
|
|
controller.cache_store = ActiveSupport::Cache::MemoryStore.new
|
|
end
|
|
|
|
def test_cache_relation_other
|
|
cache(Project.all) { concat("Hello World") }
|
|
assert_equal "Hello World", controller.cache_store.read("views/test/hello_world:fa9482a68ce25bf7589b8eddad72f736/projects-#{Project.count}")
|
|
end
|
|
|
|
def view_cache_dependencies; []; end
|
|
end
|