aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-03-19 15:45:48 -0700
committerYehuda Katz <wycats@gmail.com>2009-03-19 15:45:48 -0700
commit890321e51e0c51f61f9198d247727e98f7485899 (patch)
tree19457c8d5e9bff3d3b3b16fc4861964e5297957c /actionpack/test
parent8ab37c76608d7105c47566e79b85fcf72cb11e4b (diff)
downloadrails-890321e51e0c51f61f9198d247727e98f7485899.tar.gz
rails-890321e51e0c51f61f9198d247727e98f7485899.tar.bz2
rails-890321e51e0c51f61f9198d247727e98f7485899.zip
Get very basic layouts working.
* Required small architecture change
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_controller/abstract_controller_test.rb16
-rw-r--r--actionpack/test/new_base/render_action_test.rb23
-rw-r--r--actionpack/test/new_base/test_helper.rb1
-rw-r--r--actionpack/test/new_base/views/with_layout/happy_path/render_action_with_layout/hello_world.html.erb1
-rw-r--r--actionpack/test/new_base/views/with_layout/layouts/application.html.erb1
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