Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#948 make template inheritance optional

  • Loading branch information...
commit ce21ea783255a30e330c7218a3043801dfe9ad52 1 parent ddd85ef
@artemave artemave authored wycats committed
View
16 actionpack/lib/abstract_controller/rendering.rb
@@ -117,11 +117,14 @@ def _render_template(options) #:nodoc:
# The prefixes used in render "foo" shortcuts.
def _prefixes
prefixes = [controller_path]
- parent_controller = self.class.superclass
- until parent_controller.abstract?
- prefixes << parent_controller.controller_path
- parent_controller = parent_controller.superclass
+ if template_inheritance?
+ parent_controller = self.class.superclass
+
+ until parent_controller.abstract?
+ prefixes << parent_controller.controller_path
+ parent_controller = parent_controller.superclass
+ end
end
prefixes
@@ -173,5 +176,10 @@ def _normalize_options(options)
def _process_options(options)
end
+
+ def template_inheritance?
+ # is there a better way to check for config option being set?
+ config.template_inheritance.nil? ? true : config.template_inheritance
+ end
end
end
View
11 actionpack/test/controller/new_base/render_test.rb
@@ -53,6 +53,10 @@ class ChildRenderController < BlankRenderController
prepend_view_path ActionView::FixtureResolver.new("render/child_render/overriden_with_own_view_paths_prepended.html.erb" => "child content")
end
+ class ChildRenderWithoutInheritanceController < BlankRenderController
+ config.template_inheritance = false
+ end
+
class RenderTest < Rack::TestCase
test "render with blank" do
with_routing do |set|
@@ -135,4 +139,11 @@ class TestViewInheritance < Rack::TestCase
end
end
+ class TestNoViewInheritance < Rack::TestCase
+ test "Template from parent controller does not get picked if config.action_controller.template_inheritance = false" do
+ assert_raises(ActionView::MissingTemplate) do
+ get "/render/child_render_without_inheritance/index", {}, "action_dispatch.show_exceptions" => false
+ end
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.