aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-19 23:49:12 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-19 23:49:12 +0000
commit00111165929a31375b1100f9e7288391cfa7c6b4 (patch)
treebc5532273598eee8b6f3e5beedf7d79ca600aedb /actionpack
parentb60ba807d0ad40a2dcaa458931054e00d2795f52 (diff)
downloadrails-00111165929a31375b1100f9e7288391cfa7c6b4.tar.gz
rails-00111165929a31375b1100f9e7288391cfa7c6b4.tar.bz2
rails-00111165929a31375b1100f9e7288391cfa7c6b4.zip
Unit tests for rendering components
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@705 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/controller/components_test.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/actionpack/test/controller/components_test.rb b/actionpack/test/controller/components_test.rb
new file mode 100644
index 0000000000..b21e66dcb9
--- /dev/null
+++ b/actionpack/test/controller/components_test.rb
@@ -0,0 +1,48 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class CallerController < ActionController::Base
+ def calling_from_controller
+ render_component(:controller => "callee", :action => "being_called")
+ end
+
+ def calling_from_controller_with_params
+ render_component(:controller => "callee", :action => "being_called", :params => { "name" => "David" })
+ end
+
+ def calling_from_template
+ render_template "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>"
+ end
+
+ def rescue_action(e) raise end
+end
+
+class CalleeController < ActionController::Base
+ def being_called
+ render_text "#{@params["name"] || "Lady"} of the House, speaking"
+ end
+
+ def rescue_action(e) raise end
+end
+
+class RenderTest < Test::Unit::TestCase
+ def setup
+ @controller = CallerController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_calling_from_controller
+ get :calling_from_controller
+ assert_equal "Lady of the House, speaking", @response.body
+ end
+
+ def test_calling_from_controller_with_params
+ get :calling_from_controller_with_params
+ assert_equal "David of the House, speaking", @response.body
+ end
+
+ def test_calling_from_template
+ get :calling_from_template
+ assert_equal "Ring, ring: Lady of the House, speaking", @response.body
+ end
+end \ No newline at end of file