aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2019-02-11 17:24:24 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2019-02-11 17:55:59 -0800
commit2b6d2d20374130da469ece24842ce3b681d3b788 (patch)
treeaffbde8be64402578fbef1f5a15950e418e7b4fc /actionview/test/template
parent9439a18bf76b3b7c759340abf0d7a5fb17fc82f7 (diff)
downloadrails-2b6d2d20374130da469ece24842ce3b681d3b788.tar.gz
rails-2b6d2d20374130da469ece24842ce3b681d3b788.tar.bz2
rails-2b6d2d20374130da469ece24842ce3b681d3b788.zip
Turn lookup context in to a stack, push and pop if formats change
This commit keeps a stack of lookup contexts on the ActionView::Base instance. If a format is passed to render, we instantiate a new lookup context and push it on the stack, that way any child calls to "render" will use the same format information as the parent. This also isolates "sibling" calls to render (multiple calls to render in the same template). Fixes #35222 #34138
Diffstat (limited to 'actionview/test/template')
-rw-r--r--actionview/test/template/log_subscriber_test.rb3
-rw-r--r--actionview/test/template/render_test.rb7
2 files changed, 6 insertions, 4 deletions
diff --git a/actionview/test/template/log_subscriber_test.rb b/actionview/test/template/log_subscriber_test.rb
index 83bb651ea3..85735139c1 100644
--- a/actionview/test/template/log_subscriber_test.rb
+++ b/actionview/test/template/log_subscriber_test.rb
@@ -16,8 +16,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
view_paths = ActionController::Base.view_paths
lookup_context = ActionView::LookupContext.new(view_paths, {}, ["test"])
- renderer = ActionView::Renderer.new(lookup_context)
- @view = ActionView::Base.with_empty_template_cache.new(renderer, {})
+ @view = ActionView::Base.with_empty_template_cache.new(lookup_context, {})
ActionView::LogSubscriber.attach_to :action_view
diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb
index e36babfd25..88047fd920 100644
--- a/actionview/test/template/render_test.rb
+++ b/actionview/test/template/render_test.rb
@@ -20,7 +20,10 @@ module RenderTestCases
controller = TestController.new
- @controller_view = controller.view_context_class.with_empty_template_cache.new(controller.view_renderer, controller.view_assigns, controller)
+ @controller_view = controller.view_context_class.with_empty_template_cache.new(
+ controller.lookup_context,
+ controller.view_assigns,
+ controller)
# Reload and register danish language for testing
I18n.backend.store_translations "da", {}
@@ -83,7 +86,7 @@ module RenderTestCases
def test_render_partial_use_last_prepended_format_for_partials_with_the_same_names
@view.lookup_context.formats = [:html]
- assert_equal "\nHTML Template, but JSON partial", @view.render(template: "test/change_priority")
+ assert_equal "\nHTML Template, but HTML partial", @view.render(template: "test/change_priority")
end
def test_render_template_with_a_missing_partial_of_another_format