Revert "Merge pull request #19685 from vngrs/actionview_parent_layout_bug"

This reverts commit a9d58c77, reversing
changes made to 041c2c87.

Reason: The old behavior is how it was working in previous version of
Rails since 4.0.x so it is not safe to backport to a stable branch.

See https://github.com/rails/rails/issues/19626#issuecomment-89862258
and https://github.com/rails/rails/pull/15050#issuecomment-45333449
上级 4519727c
......@@ -315,25 +315,16 @@ def _write_layout_method # :nodoc:
name_clause
end
if self._layout_conditions.empty?
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def _layout
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def _layout
if _conditional_layout?
#{layout_definition}
else
#{name_clause}
end
private :_layout
RUBY
else
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
def _layout
if _conditional_layout?
#{layout_definition}
else
#{name_clause}
end
end
private :_layout
RUBY
end
end
private :_layout
RUBY
end
private
......
......@@ -122,14 +122,6 @@ def hello
end
end
class ParentController < LayoutTest
layout 'item'
end
class ChildController < ParentController
layout 'layout_test', only: :hello
end
class OnlyLayoutController < LayoutTest
layout 'item', :only => "hello"
end
......@@ -233,12 +225,6 @@ def test_absolute_pathed_layout
get :hello
assert_equal "layout_test.erb hello.erb", @response.body.strip
end
def test_respect_to_parent_layout
@controller = ChildController.new
get :goodbye
assert_includes @response.body, 'item.erb'
end
end
class SetsNonExistentLayoutFile < LayoutTest
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册