Skip to content

Commit

Permalink
Merge pull request #35281 from y-yagi/show_deprecated_message_instead…
Browse files Browse the repository at this point in the history
…_of_raise_exception

Show deprecated message instead of raise exception in `compiled_method_container` method
  • Loading branch information
tenderlove committed Feb 16, 2019
2 parents 5cdcf7a + 7878027 commit fdc0595
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 9 additions & 5 deletions actionview/lib/action_view/base.rb
Expand Up @@ -273,11 +273,15 @@ def run(method, locals, buffer, &block)
end

def compiled_method_container
raise NotImplementedError, <<~msg
Subclasses of ActionView::Base must implement `compiled_method_container`
or use the class method `with_empty_template_cache` for constructing
an ActionView::Base subclass that has an empty cache.
msg
if self.class == ActionView::Base
ActiveSupport::Deprecation.warn <<~eowarn
ActionView::Base instances must implement `compiled_method_container`
or use the class method `with_empty_template_cache` for constructing
an ActionView::Base instances that has an empty cache.
eowarn
end

self.class
end

def in_context(options, locals)
Expand Down
7 changes: 7 additions & 0 deletions actionview/test/template/render_test.rb
Expand Up @@ -367,6 +367,13 @@ def test_deprecated_constructor
end
end

def test_without_compiled_method_container_is_deprecated
view = ActionView::Base.with_view_paths(ActionController::Base.view_paths)
assert_deprecated("ActionView::Base instances must implement `compiled_method_container`") do
assert_equal "Hello world!", view.render(file: "test/hello_world")
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
Expand Down

0 comments on commit fdc0595

Please sign in to comment.