diff --git a/actionview/lib/action_view/layouts.rb b/actionview/lib/action_view/layouts.rb index 1fc609f2cd..9d636c8c9e 100644 --- a/actionview/lib/action_view/layouts.rb +++ b/actionview/lib/action_view/layouts.rb @@ -315,25 +315,16 @@ module ActionView 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 diff --git a/actionview/test/actionpack/controller/layout_test.rb b/actionview/test/actionpack/controller/layout_test.rb index 452634a3b7..64bc4c41d6 100644 --- a/actionview/test/actionpack/controller/layout_test.rb +++ b/actionview/test/actionpack/controller/layout_test.rb @@ -122,14 +122,6 @@ 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 @@ -233,12 +225,6 @@ 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_includes @response.body, 'item.erb' - end end class SetsNonExistentLayoutFile < LayoutTest