File tree Expand file tree Collapse file tree 2 files changed +31
-8
lines changed
test/actionpack/controller Expand file tree Collapse file tree 2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -315,16 +315,25 @@ def _write_layout_method # :nodoc:
315
315
name_clause
316
316
end
317
317
318
- self . class_eval <<-RUBY , __FILE__ , __LINE__ + 1
319
- def _layout
320
- if _conditional_layout?
318
+ if self . _layout_conditions . empty?
319
+ self . class_eval <<-RUBY , __FILE__ , __LINE__ + 1
320
+ def _layout
321
321
#{ layout_definition }
322
- else
323
- #{ name_clause }
324
322
end
325
- end
326
- private :_layout
327
- RUBY
323
+ private :_layout
324
+ RUBY
325
+ else
326
+ self . class_eval <<-RUBY , __FILE__ , __LINE__ + 1
327
+ def _layout
328
+ if _conditional_layout?
329
+ #{ layout_definition }
330
+ else
331
+ #{ name_clause }
332
+ end
333
+ end
334
+ private :_layout
335
+ RUBY
336
+ end
328
337
end
329
338
330
339
private
Original file line number Diff line number Diff line change @@ -122,6 +122,14 @@ def hello
122
122
end
123
123
end
124
124
125
+ class ParentController < LayoutTest
126
+ layout 'item'
127
+ end
128
+
129
+ class ChildController < ParentController
130
+ layout 'layout_test' , only : :hello
131
+ end
132
+
125
133
class OnlyLayoutController < LayoutTest
126
134
layout 'item' , :only => "hello"
127
135
end
@@ -225,6 +233,12 @@ def test_absolute_pathed_layout
225
233
get :hello
226
234
assert_equal "layout_test.erb hello.erb" , @response . body . strip
227
235
end
236
+
237
+ def test_respect_to_parent_layout
238
+ @controller = ChildController . new
239
+ get :goodbye
240
+ assert_template :layout => "layouts/item"
241
+ end
228
242
end
229
243
230
244
class SetsNonExistentLayoutFile < LayoutTest
You can’t perform that action at this time.
0 commit comments