mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #19685 from vngrs/actionview_parent_layout_bug
fix for actionview parent layout bug
This commit is contained in:
commit
a9d58c77da
2 changed files with 31 additions and 8 deletions
|
@ -315,16 +315,25 @@ module ActionView
|
|||
name_clause
|
||||
end
|
||||
|
||||
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||
def _layout
|
||||
if _conditional_layout?
|
||||
if self._layout_conditions.empty?
|
||||
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||
def _layout
|
||||
#{layout_definition}
|
||||
else
|
||||
#{name_clause}
|
||||
end
|
||||
end
|
||||
private :_layout
|
||||
RUBY
|
||||
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
|
||||
|
|
|
@ -122,6 +122,14 @@ class PrependsViewPathController < LayoutTest
|
|||
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
|
||||
|
@ -225,6 +233,12 @@ class LayoutSetInResponseTest < ActionController::TestCase
|
|||
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_template :layout => "layouts/item"
|
||||
end
|
||||
end
|
||||
|
||||
class SetsNonExistentLayoutFile < LayoutTest
|
||||
|
|
Loading…
Reference in a new issue