Test controller layout

This commit is contained in:
Yehuda Katz
2009-03-19 16:11:20 -07:00
parent 890321e51e
commit 7a86f8ea90
8 changed files with 40 additions and 2 deletions

View File

@@ -77,7 +77,23 @@ module HappyPath
class RenderActionWithLayoutController < ActionController::Base2
# Set the view path to an application view structure with layouts
self.view_paths = [File.join(File.dirname(__FILE__), 'views', 'with_layout')]
self.view_paths = [File.join(File.dirname(__FILE__), 'views', 'with_application_layout')]
def hello_world
render :action => "hello_world"
end
end
class RenderActionWithControllerLayoutController < ActionController::Base2
self.view_paths = [File.join(File.dirname(__FILE__), 'views', 'with_controller_layout')]
def hello_world
render :action => "hello_world"
end
end
class RenderActionWithControllerLayoutFirstController < ActionController::Base2
self.view_paths = [File.join(File.dirname(__FILE__), 'views', 'with_both_layouts')]
def hello_world
render :action => "hello_world"
@@ -94,5 +110,22 @@ module HappyPath
assert_body "OHAI Hello World! KTHXBAI"
assert_status 200
end
class TestRenderActionWithControllerLayout < SimpleRouteCase
describe "Render hello_world and implicitly use <controller_path>.html.erb as a layout."
get "/happy_path/render_action_with_controller_layout/hello_world"
assert_body "With Controller Layout! Hello World! KTHXBAI"
assert_status 200
end
class TestRenderActionWithControllerLayoutFirst < SimpleRouteCase
describe "Render hello_world and implicitly use <controller_path>.html.erb over application.html.erb as a layout"
get "/happy_path/render_action_with_controller_layout_first/hello_world"
assert_body "With Controller Layout! Hello World! KTHXBAI"
assert_status 200
end
# TODO: Implement a FixtureViewPath
end

View File

@@ -0,0 +1 @@
OHAI <%= yield %> KTHXBAI

View File

@@ -0,0 +1 @@
With Controller Layout! <%= yield %> KTHXBAI

View File

@@ -0,0 +1 @@
With Controller Layout! <%= yield %> KTHXBAI