diff options
Diffstat (limited to 'actionpack/test')
5 files changed, 40 insertions, 2 deletions
diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb index 22fc1a8c41..31c28a5c48 100644 --- a/actionpack/test/abstract_controller/abstract_controller_test.rb +++ b/actionpack/test/abstract_controller/abstract_controller_test.rb @@ -28,7 +28,14 @@ module AbstractController # ==== class RenderingController < AbstractController::Base include Renderer - + + def _prefix() end + + def render(name = action_name, options = {}) + options[:_prefix] = _prefix + super + end + append_view_path File.expand_path(File.join(File.dirname(__FILE__), "views")) end @@ -121,7 +128,12 @@ module AbstractController def _layout self.class.layout(formats) - end + end + + def render_to_string(name = action_name, options = {}) + options[:_layout] = options[:layout] || _layout + super + end end class Me4 < WithLayouts diff --git a/actionpack/test/new_base/render_action_test.rb b/actionpack/test/new_base/render_action_test.rb index b6e98f82aa..99482cd4a1 100644 --- a/actionpack/test/new_base/render_action_test.rb +++ b/actionpack/test/new_base/render_action_test.rb @@ -2,6 +2,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") module HappyPath + # This has no layout and it works class RenderActionController < ActionController::Base2 def render_action_hello_world @@ -71,5 +72,27 @@ module HappyPath assert_body "Hello world!" assert_status 200 end + + # # ==== Render actions with layouts ==== + + 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')] + + def hello_world + render :action => "hello_world" + end + end + + class TestRenderActionWithLayout < SimpleRouteCase + describe %( + Render hello_world and implicitly use application.html.erb as a layout if + no layout is specified and no controller layout is present + ) + + get "/happy_path/render_action_with_layout/hello_world" + assert_body "OHAI Hello World! KTHXBAI" + assert_status 200 + end end
\ No newline at end of file diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb index 7a1adc3755..af790aa5dd 100644 --- a/actionpack/test/new_base/test_helper.rb +++ b/actionpack/test/new_base/test_helper.rb @@ -33,6 +33,7 @@ module ActionController include ActionController::HideActions include ActionController::UrlFor include ActionController::Renderer + include ActionController::Layouts def self.inherited(klass) @subclasses ||= [] 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 new file mode 100644 index 0000000000..c57eff55eb --- /dev/null +++ b/actionpack/test/new_base/views/with_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_layout/layouts/application.html.erb b/actionpack/test/new_base/views/with_layout/layouts/application.html.erb new file mode 100644 index 0000000000..25f839fded --- /dev/null +++ b/actionpack/test/new_base/views/with_layout/layouts/application.html.erb @@ -0,0 +1 @@ +OHAI <%= yield %> KTHXBAI
\ No newline at end of file |