aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/actionpack/abstract
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-05-17 11:28:40 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2016-05-17 11:28:51 -0700
commitd6bac046922fcee05366d26d75349dde70d25f6b (patch)
tree486bad10a28c4b93bbde0482f3bb6217d0a3e516 /actionview/test/actionpack/abstract
parent17f04e446a6b3d5ca457e9666e06ee4eccdfa9c2 (diff)
downloadrails-d6bac046922fcee05366d26d75349dde70d25f6b.tar.gz
rails-d6bac046922fcee05366d26d75349dde70d25f6b.tar.bz2
rails-d6bac046922fcee05366d26d75349dde70d25f6b.zip
keep layouts + locals from bloating the cache
Using locals will cause layouts to be cached multiple times in the template cache. This commit removes locals from consideration when looking up the layout.
Diffstat (limited to 'actionview/test/actionpack/abstract')
-rw-r--r--actionview/test/actionpack/abstract/layouts_test.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/actionview/test/actionpack/abstract/layouts_test.rb b/actionview/test/actionpack/abstract/layouts_test.rb
index 8c80a2d2cf..72765dc7f5 100644
--- a/actionview/test/actionpack/abstract/layouts_test.rb
+++ b/actionview/test/actionpack/abstract/layouts_test.rb
@@ -224,6 +224,25 @@ module AbstractControllerTests
assert_equal "With String hello less than 3 bar", controller.response_body
end
+ test "cache should not grow when locals change for a string template" do
+ cache = WithString.view_paths.paths.first.instance_variable_get(:@cache)
+
+ controller = WithString.new
+ controller.process(:index) # heat the cache
+
+ size = cache.size
+
+ 10.times do |x|
+ controller = WithString.new
+ controller.define_singleton_method :index do
+ render :template => ActionView::Template::Text.new("Hello string!"), :locals => { :"x#{x}" => :omg }
+ end
+ controller.process(:index)
+ end
+
+ assert_equal size, cache.size
+ end
+
test "when layout is specified as a string, render with that layout" do
controller = WithString.new
controller.process(:index)