aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2016-02-15 22:47:44 +0100
committerKasper Timm Hansen <kaspth@gmail.com>2016-02-20 16:54:32 +0100
commitb4558c10fb8f5379ffe23860c9ad1ee7a227de44 (patch)
treee970d2796ba27d9d6d5ef7bf4a747103f69104d6 /actionpack
parent454bc1deab3b60f6b4cbe36227471ed40f4c38f9 (diff)
downloadrails-b4558c10fb8f5379ffe23860c9ad1ee7a227de44.tar.gz
rails-b4558c10fb8f5379ffe23860c9ad1ee7a227de44.tar.bz2
rails-b4558c10fb8f5379ffe23860c9ad1ee7a227de44.zip
Make collection caching explicit.
Having collection caching that wraps templates and automatically tries to infer if they are cachable proved to be too much of a hassle. We'd rather have it be something you explicitly turn on. This removes much of the code and docs to explain the previous automatic behavior. This change also removes scoped cache keys and passing cache_options.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/controller/caching_test.rb21
-rw-r--r--actionpack/test/fixtures/collection_cache/index.html.erb2
2 files changed, 6 insertions, 17 deletions
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 7556f984f2..754ac144cc 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -381,19 +381,14 @@ class CollectionCacheController < ActionController::Base
render 'index'
end
- def index_explicit_render
+ def index_explicit_render_in_controller
@customers = [Customer.new('david', 1)]
- render partial: 'customers/customer', collection: @customers
+ render partial: 'customers/customer', collection: @customers, cached: true
end
def index_with_comment
@customers = [Customer.new('david', 1)]
- render partial: 'customers/commented_customer', collection: @customers, as: :customer
- end
-
- def index_with_callable_cache_key
- @customers = [Customer.new('david', 1)]
- render @customers, cache: -> customer { 'cached_david' }
+ render partial: 'customers/commented_customer', collection: @customers, as: :customer, cached: true
end
end
@@ -404,7 +399,7 @@ class AutomaticCollectionCacheTest < ActionController::TestCase
@controller.perform_caching = true
@controller.partial_rendered_times = 0
@controller.cache_store = ActiveSupport::Cache::MemoryStore.new
- ActionView::PartialRenderer.collection_cache = @controller.cache_store
+ ActionView::PartialRenderer.collection_cache = ActiveSupport::Cache::MemoryStore.new
end
def test_collection_fetches_cached_views
@@ -427,7 +422,7 @@ class AutomaticCollectionCacheTest < ActionController::TestCase
end
def test_explicit_render_call_with_options
- get :index_explicit_render
+ get :index_explicit_render_in_controller
assert_select ':root', "david, 1"
end
@@ -440,12 +435,6 @@ class AutomaticCollectionCacheTest < ActionController::TestCase
assert_equal 1, @controller.partial_rendered_times
end
- def test_caching_with_callable_cache_key
- get :index_with_callable_cache_key
- assert_customer_cached 'cached_david', 'david, 1'
- assert_customer_cached 'david/1', 'david, 1'
- end
-
private
def assert_customer_cached(key, content)
assert_match content,
diff --git a/actionpack/test/fixtures/collection_cache/index.html.erb b/actionpack/test/fixtures/collection_cache/index.html.erb
index 521b1450df..853e501ab4 100644
--- a/actionpack/test/fixtures/collection_cache/index.html.erb
+++ b/actionpack/test/fixtures/collection_cache/index.html.erb
@@ -1 +1 @@
-<%= render @customers %> \ No newline at end of file
+<%= render partial: 'customers/customer', collection: @customers, cached: true %>