From 7a86f8ea90f88a388b3093471d60b3019ea8ebac Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Thu, 19 Mar 2009 16:11:20 -0700 Subject: Test controller layout --- actionpack/test/new_base/render_action_test.rb | 37 ++++++++++++++++++++-- .../render_action_with_layout/hello_world.html.erb | 1 + .../layouts/application.html.erb | 1 + .../hello_world.html.erb | 1 + .../with_both_layouts/layouts/application.html.erb | 1 + ...er_action_with_controller_layout_first.html.erb | 1 + .../hello_world.html.erb | 1 + .../render_action_with_controller_layout.html.erb | 1 + .../render_action_with_layout/hello_world.html.erb | 1 - .../views/with_layout/layouts/application.html.erb | 1 - 10 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 actionpack/test/new_base/views/with_application_layout/happy_path/render_action_with_layout/hello_world.html.erb create mode 100644 actionpack/test/new_base/views/with_application_layout/layouts/application.html.erb create mode 100644 actionpack/test/new_base/views/with_both_layouts/happy_path/render_action_with_controller_layout_first/hello_world.html.erb create mode 100644 actionpack/test/new_base/views/with_both_layouts/layouts/application.html.erb create mode 100644 actionpack/test/new_base/views/with_both_layouts/layouts/happy_path/render_action_with_controller_layout_first.html.erb create mode 100644 actionpack/test/new_base/views/with_controller_layout/happy_path/render_action_with_controller_layout/hello_world.html.erb create mode 100644 actionpack/test/new_base/views/with_controller_layout/layouts/happy_path/render_action_with_controller_layout.html.erb delete mode 100644 actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb delete mode 100644 actionpack/test/new_base/views/with_layout/layouts/application.html.erb (limited to 'actionpack/test') diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb index 99482cd4a1..188fb44265 100644 --- a/actionpack/test/new_base/render_action_test.rb +++ b/actionpack/test/new_base/render_action_test.rb @@ -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 .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 .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 \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_application_layout/happy_path/render_action_with_layout/hello_world.html.erb b/actionpack/test/new_base/views/with_application_layout/happy_path/render_action_with_layout/hello_world.html.erb new file mode 100644 index 0000000000..c57eff55eb --- /dev/null +++ b/actionpack/test/new_base/views/with_application_layout/happy_path/render_action_with_layout/hello_world.html.erb @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_application_layout/layouts/application.html.erb b/actionpack/test/new_base/views/with_application_layout/layouts/application.html.erb new file mode 100644 index 0000000000..25f839fded --- /dev/null +++ b/actionpack/test/new_base/views/with_application_layout/layouts/application.html.erb @@ -0,0 +1 @@ +OHAI <%= yield %> KTHXBAI \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_both_layouts/happy_path/render_action_with_controller_layout_first/hello_world.html.erb b/actionpack/test/new_base/views/with_both_layouts/happy_path/render_action_with_controller_layout_first/hello_world.html.erb new file mode 100644 index 0000000000..c57eff55eb --- /dev/null +++ b/actionpack/test/new_base/views/with_both_layouts/happy_path/render_action_with_controller_layout_first/hello_world.html.erb @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_both_layouts/layouts/application.html.erb b/actionpack/test/new_base/views/with_both_layouts/layouts/application.html.erb new file mode 100644 index 0000000000..25f839fded --- /dev/null +++ b/actionpack/test/new_base/views/with_both_layouts/layouts/application.html.erb @@ -0,0 +1 @@ +OHAI <%= yield %> KTHXBAI \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_both_layouts/layouts/happy_path/render_action_with_controller_layout_first.html.erb b/actionpack/test/new_base/views/with_both_layouts/layouts/happy_path/render_action_with_controller_layout_first.html.erb new file mode 100644 index 0000000000..43d89fde52 --- /dev/null +++ b/actionpack/test/new_base/views/with_both_layouts/layouts/happy_path/render_action_with_controller_layout_first.html.erb @@ -0,0 +1 @@ +With Controller Layout! <%= yield %> KTHXBAI \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_controller_layout/happy_path/render_action_with_controller_layout/hello_world.html.erb b/actionpack/test/new_base/views/with_controller_layout/happy_path/render_action_with_controller_layout/hello_world.html.erb new file mode 100644 index 0000000000..c57eff55eb --- /dev/null +++ b/actionpack/test/new_base/views/with_controller_layout/happy_path/render_action_with_controller_layout/hello_world.html.erb @@ -0,0 +1 @@ +Hello World! \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_controller_layout/layouts/happy_path/render_action_with_controller_layout.html.erb b/actionpack/test/new_base/views/with_controller_layout/layouts/happy_path/render_action_with_controller_layout.html.erb new file mode 100644 index 0000000000..43d89fde52 --- /dev/null +++ b/actionpack/test/new_base/views/with_controller_layout/layouts/happy_path/render_action_with_controller_layout.html.erb @@ -0,0 +1 @@ +With Controller Layout! <%= yield %> KTHXBAI \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb b/actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb deleted file mode 100644 index c57eff55eb..0000000000 --- a/actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb +++ /dev/null @@ -1 +0,0 @@ -Hello World! \ No newline at end of file diff --git a/actionpack/test/new_base/views/with_layout/layouts/application.html.erb b/actionpack/test/new_base/views/with_layout/layouts/application.html.erb deleted file mode 100644 index 25f839fded..0000000000 --- a/actionpack/test/new_base/views/with_layout/layouts/application.html.erb +++ /dev/null @@ -1 +0,0 @@ -OHAI <%= yield %> KTHXBAI \ No newline at end of file -- cgit v1.2.3