Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove deprecated fragment_cache_key helper in favor of `combined_f…
…ragment_cache_key`
  • Loading branch information
rafaelfranca committed Jan 17, 2019
1 parent 13ddc92 commit e70d3df
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
4 changes: 4 additions & 0 deletions actionpack/CHANGELOG.md
@@ -1,3 +1,7 @@
* Remove deprecated `fragment_cache_key` helper in favor of `combined_fragment_cache_key`.

*Rafael Mendonça França*

* Remove deprecated methods in `ActionDispatch::TestResponse`.

`#success?`, `missing?` and `error?` were deprecated in Rails 5.2 in favor of
Expand Down
19 changes: 0 additions & 19 deletions actionpack/lib/abstract_controller/caching/fragments.rb
Expand Up @@ -60,25 +60,6 @@ def fragment_cache_key(value = nil, &key)
end
end

# Given a key (as described in +expire_fragment+), returns
# a key suitable for use in reading, writing, or expiring a
# cached fragment. All keys begin with <tt>views/</tt>,
# followed by any controller-wide key prefix values, ending
# with the specified +key+ value. The key is expanded using
# ActiveSupport::Cache.expand_cache_key.
def fragment_cache_key(key)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Calling fragment_cache_key directly is deprecated and will be removed in Rails 6.0.
All fragment accessors now use the combined_fragment_cache_key method that retains the key as an array,
such that the caching stores can interrogate the parts for cache versions used in
recyclable cache keys.
MSG

head = self.class.fragment_cache_keys.map { |k| instance_exec(&k) }
tail = key.is_a?(Hash) ? url_for(key).split("://").last : key
ActiveSupport::Cache.expand_cache_key([*head, *tail], :views)
end

# Given a key (as described in +expire_fragment+), returns
# a key array suitable for use in reading, writing, or expiring a
# cached fragment. All keys begin with <tt>:views</tt>,
Expand Down
8 changes: 0 additions & 8 deletions actionpack/test/controller/caching_test.rb
Expand Up @@ -60,14 +60,6 @@ def setup
@m2v2 = ModelWithKeyAndVersion.new("model/2", "2")
end

def test_fragment_cache_key
assert_deprecated do
assert_equal "views/what a key", @controller.fragment_cache_key("what a key")
assert_equal "views/test.host/fragment_caching_test/some_action",
@controller.fragment_cache_key(controller: "fragment_caching_test", action: "some_action")
end
end

def test_combined_fragment_cache_key
assert_equal [ :views, "what a key" ], @controller.combined_fragment_cache_key("what a key")
assert_equal [ :views, "test.host/fragment_caching_test/some_action" ],
Expand Down

0 comments on commit e70d3df

Please sign in to comment.