diff options
Diffstat (limited to 'actionview/test')
-rw-r--r-- | actionview/test/abstract_unit.rb | 6 | ||||
-rw-r--r-- | actionview/test/actionpack/controller/layout_test.rb | 4 | ||||
-rw-r--r-- | actionview/test/actionpack/controller/view_paths_test.rb | 4 | ||||
-rw-r--r-- | actionview/test/activerecord/multifetch_cache_test.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/capture_helper_test.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/compiled_templates_test.rb | 4 | ||||
-rw-r--r-- | actionview/test/template/dependency_tracker_test.rb | 4 | ||||
-rw-r--r-- | actionview/test/template/render_test.rb | 27 | ||||
-rw-r--r-- | actionview/test/template/streaming_render_test.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/test_case_test.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/translation_helper_test.rb | 2 |
11 files changed, 39 insertions, 20 deletions
diff --git a/actionview/test/abstract_unit.rb b/actionview/test/abstract_unit.rb index d71944e938..acc2ed029b 100644 --- a/actionview/test/abstract_unit.rb +++ b/actionview/test/abstract_unit.rb @@ -48,7 +48,7 @@ module RenderERBUtils @view ||= begin path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) view_paths = ActionView::PathSet.new([path]) - ActionView::Base.new(view_paths) + ActionView::Base.with_view_paths(view_paths) end end @@ -58,10 +58,10 @@ module RenderERBUtils template = ActionView::Template.new( string.strip, "test template", - ActionView::Template::Handlers::ERB, + ActionView::Template.handler_for_extension(:erb), {}) - template.render(ActionView::Base.new, {}).strip + template.render(ActionView::Base.empty, {}).strip end end diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb index 6d5c97b7fd..838b564c5d 100644 --- a/actionview/test/actionpack/controller/layout_test.rb +++ b/actionview/test/actionpack/controller/layout_test.rb @@ -70,7 +70,7 @@ class LayoutAutoDiscoveryTest < ActionController::TestCase end def test_third_party_template_library_auto_discovers_layout - with_template_handler :mab, lambda { |template| template.source.inspect } do + with_template_handler :mab, lambda { |template, source| source.inspect } do @controller = ThirdPartyTemplateLibraryController.new get :hello assert_response :success @@ -212,7 +212,7 @@ class LayoutSetInResponseTest < ActionController::TestCase end def test_layout_set_when_using_render - with_template_handler :mab, lambda { |template| template.source.inspect } do + with_template_handler :mab, lambda { |template, source| source.inspect } do @controller = SetsLayoutInRenderController.new get :hello assert_includes @response.body, "layouts/third_party_template_library.mab" diff --git a/actionview/test/actionpack/controller/view_paths_test.rb b/actionview/test/actionpack/controller/view_paths_test.rb index 7f3fe0fa08..c5238dd746 100644 --- a/actionview/test/actionpack/controller/view_paths_test.rb +++ b/actionview/test/actionpack/controller/view_paths_test.rb @@ -77,7 +77,7 @@ class ViewLoadPathsTest < ActionController::TestCase end def test_template_appends_view_path_correctly - @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) + @controller.instance_variable_set :@template, ActionView::Base.with_view_paths(TestController.view_paths, {}, @controller) class_view_paths = TestController.view_paths @controller.append_view_path "foo" @@ -89,7 +89,7 @@ class ViewLoadPathsTest < ActionController::TestCase end def test_template_prepends_view_path_correctly - @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) + @controller.instance_variable_set :@template, ActionView::Base.with_view_paths(TestController.view_paths, {}, @controller) class_view_paths = TestController.view_paths @controller.prepend_view_path "baz" diff --git a/actionview/test/activerecord/multifetch_cache_test.rb b/actionview/test/activerecord/multifetch_cache_test.rb index 12be069e69..229b4e56d0 100644 --- a/actionview/test/activerecord/multifetch_cache_test.rb +++ b/actionview/test/activerecord/multifetch_cache_test.rb @@ -19,7 +19,7 @@ class MultifetchCacheTest < ActiveRecordTestCase def combined_fragment_cache_key(key) [ :views, key ] end - end.new(view_paths, {}) + end.with_view_paths(view_paths, {}) end def test_only_preloading_for_records_that_miss_the_cache diff --git a/actionview/test/template/capture_helper_test.rb b/actionview/test/template/capture_helper_test.rb index e172497c88..45070674ad 100644 --- a/actionview/test/template/capture_helper_test.rb +++ b/actionview/test/template/capture_helper_test.rb @@ -5,7 +5,7 @@ require "abstract_unit" class CaptureHelperTest < ActionView::TestCase def setup super - @av = ActionView::Base.new + @av = ActionView::Base.empty @view_flow = ActionView::OutputFlow.new end diff --git a/actionview/test/template/compiled_templates_test.rb b/actionview/test/template/compiled_templates_test.rb index 3cd6448e38..ded4786e62 100644 --- a/actionview/test/template/compiled_templates_test.rb +++ b/actionview/test/template/compiled_templates_test.rb @@ -72,13 +72,13 @@ class CompiledTemplatesTest < ActiveSupport::TestCase def render_with_cache(*args) view_paths = ActionController::Base.view_paths - ActionView::Base.new(view_paths, {}).render(*args) + ActionView::Base.with_view_paths(view_paths, {}).render(*args) end def render_without_cache(*args) path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH) view_paths = ActionView::PathSet.new([path]) - ActionView::Base.new(view_paths, {}).render(*args) + ActionView::Base.with_view_paths(view_paths, {}).render(*args) end def modify_template(template, content) diff --git a/actionview/test/template/dependency_tracker_test.rb b/actionview/test/template/dependency_tracker_test.rb index ef7aeac039..42cb14a18a 100644 --- a/actionview/test/template/dependency_tracker_test.rb +++ b/actionview/test/template/dependency_tracker_test.rb @@ -17,8 +17,8 @@ class FakeTemplate end end -Neckbeard = lambda { |template| template.source } -Bowtie = lambda { |template| template.source } +Neckbeard = lambda { |template, source| source } +Bowtie = lambda { |template, source| source } class DependencyTrackerTest < ActionView::TestCase def tracker diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index afe68b7ff0..f5d251da20 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -15,7 +15,7 @@ module RenderTestCases def combined_fragment_cache_key(key) [ :views, key ] end - end.new(paths, @assigns) + end.with_view_paths(paths, @assigns) @controller_view = TestController.new.view_context @@ -336,6 +336,16 @@ module RenderTestCases assert_equal "Hello: davidHello: mary", @view.render(partial: "test/customer", collection: customers) end + def test_deprecated_constructor + assert_deprecated do + ActionView::Base.new + end + + assert_deprecated do + ActionView::Base.new ["/a"] + end + end + def test_render_partial_without_object_does_not_put_partial_name_to_local_assigns assert_equal "false", @view.render(partial: "test/partial_name_in_local_assigns") end @@ -440,13 +450,22 @@ module RenderTestCases assert_equal "Hello, World!", @view.render(inline: "Hello, World!", type: :bar) end - CustomHandler = lambda do |template| + CustomHandler = lambda do |template, source| "@output_buffer = ''.dup\n" \ - "@output_buffer << 'source: #{template.source.inspect}'\n" + "@output_buffer << 'source: #{source.inspect}'\n" end def test_render_inline_with_render_from_to_proc - ActionView::Template.register_template_handler :ruby_handler, :source.to_proc + ActionView::Template.register_template_handler :ruby_handler, lambda { |_, source| source } + assert_equal "3", @view.render(inline: "(1 + 2).to_s", type: :ruby_handler) + ensure + ActionView::Template.unregister_template_handler :ruby_handler + end + + def test_render_inline_with_render_from_to_proc_deprecated + assert_deprecated do + ActionView::Template.register_template_handler :ruby_handler, :source.to_proc + end assert_equal "3", @view.render(inline: "(1 + 2).to_s", type: :ruby_handler) ensure ActionView::Template.unregister_template_handler :ruby_handler diff --git a/actionview/test/template/streaming_render_test.rb b/actionview/test/template/streaming_render_test.rb index f196c42c4f..dda2095013 100644 --- a/actionview/test/template/streaming_render_test.rb +++ b/actionview/test/template/streaming_render_test.rb @@ -9,7 +9,7 @@ class SetupFiberedBase < ActiveSupport::TestCase def setup view_paths = ActionController::Base.view_paths @assigns = { secret: "in the sauce", name: nil } - @view = ActionView::Base.new(view_paths, @assigns) + @view = ActionView::Base.with_view_paths(view_paths, @assigns) @controller_view = TestController.new.view_context end diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index 976b6bc77e..ab3ababba4 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -52,7 +52,7 @@ module ActionView end test "retrieve non existing config values" do - assert_nil ActionView::Base.new.config.something_odd + assert_nil ActionView::Base.empty.config.something_odd end test "works without testing a helper module" do diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index e756348938..d04e68e182 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -36,7 +36,7 @@ class TranslationHelperTest < ActiveSupport::TestCase } } ) - @view = ::ActionView::Base.new(ActionController::Base.view_paths, {}) + @view = ::ActionView::Base.with_view_paths(ActionController::Base.view_paths, {}) end teardown do |