Skip to content

Commit

Permalink
Remove deprecated support to pass an object that is not a `ActionView…
Browse files Browse the repository at this point in the history
…::LookupContext` as the first argument in `ActionView::Base#initialize`
  • Loading branch information
rafaelfranca committed Oct 30, 2020
1 parent c3b0872 commit 05f234d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 40 deletions.
5 changes: 5 additions & 0 deletions actionview/CHANGELOG.md
@@ -1,3 +1,8 @@
* Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
in `ActionView::Base#initialize`.

*Rafael Mendonça França*

* Remove deprecated `format` argument `ActionView::Base#initialize`.

*Rafael Mendonça França*
Expand Down
28 changes: 2 additions & 26 deletions actionview/lib/action_view/base.rb
Expand Up @@ -213,21 +213,6 @@ def assign(new_assigns) # :nodoc:

# :stopdoc:

def self.build_lookup_context(context)
case context
when ActionView::Renderer
context.lookup_context
when Array
ActionView::LookupContext.new(context)
when ActionView::PathSet
ActionView::LookupContext.new(context)
when nil
ActionView::LookupContext.new([])
else
raise NotImplementedError, context.class.name
end
end

def self.empty
with_view_paths([])
end
Expand All @@ -242,19 +227,10 @@ def self.with_context(context, assigns = {}, controller = nil)

# :startdoc:

def initialize(lookup_context = nil, assigns = {}, controller = nil) #:nodoc:
def initialize(lookup_context, assigns = {}, controller = nil) #:nodoc:
@_config = ActiveSupport::InheritableOptions.new

case lookup_context
when ActionView::LookupContext
@lookup_context = lookup_context
else
ActiveSupport::Deprecation.warn <<~eowarn.squish
ActionView::Base instances should be constructed with a lookup context,
assignments, and a controller.
eowarn
@lookup_context = self.class.build_lookup_context(lookup_context)
end
@lookup_context = lookup_context

@view_renderer = ActionView::Renderer.new @lookup_context
@current_template = nil
Expand Down
14 changes: 0 additions & 14 deletions actionview/test/template/render_test.rb
Expand Up @@ -378,20 +378,6 @@ def test_render_partial_collection_for_non_array
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

assert_deprecated do
ActionView::Base.new ActionView::PathSet.new ["/a"]
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
Expand Down
3 changes: 3 additions & 0 deletions guides/source/6_1_release_notes.md
Expand Up @@ -55,6 +55,9 @@ Please refer to the [Changelog][action-pack] for detailed changes.

### Removals

* Remove deprecated support to pass an object that is not a `ActionView::LookupContext` as the first argument
in `ActionView::Base#initialize`.

* Remove deprecated `format` argument `ActionView::Base#initialize`.

* Remove deprecated `ActionView::Template#refresh`.
Expand Down

0 comments on commit 05f234d

Please sign in to comment.