#948 make template inheritance optional
This commit is contained in:
parent
ddd85ef9c6
commit
ce21ea7832
|
@ -117,11 +117,14 @@ module AbstractController
|
||||||
# The prefixes used in render "foo" shortcuts.
|
# The prefixes used in render "foo" shortcuts.
|
||||||
def _prefixes
|
def _prefixes
|
||||||
prefixes = [controller_path]
|
prefixes = [controller_path]
|
||||||
parent_controller = self.class.superclass
|
|
||||||
|
|
||||||
until parent_controller.abstract?
|
if template_inheritance?
|
||||||
prefixes << parent_controller.controller_path
|
parent_controller = self.class.superclass
|
||||||
parent_controller = parent_controller.superclass
|
|
||||||
|
until parent_controller.abstract?
|
||||||
|
prefixes << parent_controller.controller_path
|
||||||
|
parent_controller = parent_controller.superclass
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
prefixes
|
prefixes
|
||||||
|
@ -173,5 +176,10 @@ module AbstractController
|
||||||
|
|
||||||
def _process_options(options)
|
def _process_options(options)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -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")
|
prepend_view_path ActionView::FixtureResolver.new("render/child_render/overriden_with_own_view_paths_prepended.html.erb" => "child content")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ChildRenderWithoutInheritanceController < BlankRenderController
|
||||||
|
config.template_inheritance = false
|
||||||
|
end
|
||||||
|
|
||||||
class RenderTest < Rack::TestCase
|
class RenderTest < Rack::TestCase
|
||||||
test "render with blank" do
|
test "render with blank" do
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
|
@ -135,4 +139,11 @@ module Render
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue