aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_base/render_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller/new_base/render_test.rb')
-rw-r--r--actionpack/test/controller/new_base/render_test.rb43
1 files changed, 42 insertions, 1 deletions
diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb
index df97a2725b..a520934c5b 100644
--- a/actionpack/test/controller/new_base/render_test.rb
+++ b/actionpack/test/controller/new_base/render_test.rb
@@ -6,7 +6,11 @@ module Render
"render/blank_render/index.html.erb" => "Hello world!",
"render/blank_render/access_request.html.erb" => "The request: <%= request.method.to_s.upcase %>",
"render/blank_render/access_action_name.html.erb" => "Action Name: <%= action_name %>",
- "render/blank_render/access_controller_name.html.erb" => "Controller Name: <%= controller_name %>"
+ "render/blank_render/access_controller_name.html.erb" => "Controller Name: <%= controller_name %>",
+ "render/blank_render/overriden_with_own_view_paths_appended.html.erb" => "parent content",
+ "render/blank_render/overriden_with_own_view_paths_prepended.html.erb" => "parent content",
+ "render/blank_render/overriden.html.erb" => "parent content",
+ "render/child_render/overriden.html.erb" => "child content"
)]
def index
@@ -21,6 +25,15 @@ module Render
render :action => "access_action_name"
end
+ def overriden_with_own_view_paths_appended
+ end
+
+ def overriden_with_own_view_paths_prepended
+ end
+
+ def overriden
+ end
+
private
def secretz
@@ -35,6 +48,11 @@ module Render
end
end
+ class ChildRenderController < BlankRenderController
+ append_view_path ActionView::FixtureResolver.new("render/child_render/overriden_with_own_view_paths_appended.html.erb" => "child content")
+ prepend_view_path ActionView::FixtureResolver.new("render/child_render/overriden_with_own_view_paths_prepended.html.erb" => "child content")
+ end
+
class RenderTest < Rack::TestCase
test "render with blank" do
with_routing do |set|
@@ -94,4 +112,27 @@ module Render
assert_body "Controller Name: blank_render"
end
end
+
+ class TestViewInheritance < Rack::TestCase
+ test "Template from child controller gets picked over parent one" do
+ get "/render/child_render/overriden"
+ assert_body "child content"
+ end
+
+ test "Template from child controller with custom view_paths prepended gets picked over parent one" do
+ get "/render/child_render/overriden_with_own_view_paths_prepended"
+ assert_body "child content"
+ end
+
+ test "Template from child controller with custom view_paths appended gets picked over parent one" do
+ get "/render/child_render/overriden_with_own_view_paths_appended"
+ assert_body "child content"
+ end
+
+ test "Template from parent controller gets picked if missing in child controller" do
+ get "/render/child_render/index"
+ assert_body "Hello world!"
+ end
+ end
+
end