aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorartemave <artemave@gmail.com>2010-10-01 17:49:30 +0000
committerwycats <wycats@gmail.com>2010-12-26 22:32:15 -0800
commitce21ea783255a30e330c7218a3043801dfe9ad52 (patch)
treef8c961650062e92251ce1c5c07a15ad9c8242689 /actionpack
parentddd85ef9c6a6297a8ff28816d907bbbf2eae5856 (diff)
downloadrails-ce21ea783255a30e330c7218a3043801dfe9ad52.tar.gz
rails-ce21ea783255a30e330c7218a3043801dfe9ad52.tar.bz2
rails-ce21ea783255a30e330c7218a3043801dfe9ad52.zip
#948 make template inheritance optional
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb16
-rw-r--r--actionpack/test/controller/new_base/render_test.rb11
2 files changed, 23 insertions, 4 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index 06f4441609..01dd4ffeb1 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -117,11 +117,14 @@ module AbstractController
# 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 @@ module AbstractController
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
diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb
index a520934c5b..f5baa829b6 100644
--- a/actionpack/test/controller/new_base/render_test.rb
+++ b/actionpack/test/controller/new_base/render_test.rb
@@ -53,6 +53,10 @@ module Render
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 @@ module Render
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