Permalink
Browse files

#948 make template inheritance optional

  • Loading branch information...
1 parent ddd85ef commit ce21ea783255a30e330c7218a3043801dfe9ad52 @artemave artemave committed with wycats Oct 1, 2010
@@ -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
@@ -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

0 comments on commit ce21ea7

Please sign in to comment.