aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-19 23:51:59 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-19 23:51:59 +0000
commitcf6d77600ac132fd3f840c8e57d8e139da39f675 (patch)
treeeeb791ea631ab4a7f1934fa6745d1081b5cc0b26 /actionpack
parent00111165929a31375b1100f9e7288391cfa7c6b4 (diff)
downloadrails-cf6d77600ac132fd3f840c8e57d8e139da39f675.tar.gz
rails-cf6d77600ac132fd3f840c8e57d8e139da39f675.tar.bz2
rails-cf6d77600ac132fd3f840c8e57d8e139da39f675.zip
Tests and tweaks for components
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@706 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/components.rb2
-rw-r--r--actionpack/test/controller/components_test.rb13
2 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb
index 86bf5d8138..0d17d51ef8 100644
--- a/actionpack/lib/action_controller/components.rb
+++ b/actionpack/lib/action_controller/components.rb
@@ -22,7 +22,7 @@ module ActionController #:nodoc:
def component_request(options)
component_request = @request.dup
- component_request.send(:instance_variable_set, :@parameters, options[:params].merge({ "controller" => options[:controller], "action" => options[:action] }))
+ component_request.send(:instance_variable_set, :@parameters, (options[:params] || {}).merge({ "controller" => options[:controller], "action" => options[:action] }))
component_request
end
end
diff --git a/actionpack/test/controller/components_test.rb b/actionpack/test/controller/components_test.rb
index b21e66dcb9..36f15d8df5 100644
--- a/actionpack/test/controller/components_test.rb
+++ b/actionpack/test/controller/components_test.rb
@@ -9,6 +9,10 @@ class CallerController < ActionController::Base
render_component(:controller => "callee", :action => "being_called", :params => { "name" => "David" })
end
+ def calling_from_controller_with_different_status_code
+ render_component(:controller => "callee", :action => "blowing_up")
+ end
+
def calling_from_template
render_template "Ring, ring: <%= render_component(:controller => 'callee', :action => 'being_called') %>"
end
@@ -20,6 +24,10 @@ class CalleeController < ActionController::Base
def being_called
render_text "#{@params["name"] || "Lady"} of the House, speaking"
end
+
+ def blowing_up
+ render_text "It's game over, man, just game over, man!", "500 Internal Server Error"
+ end
def rescue_action(e) raise end
end
@@ -40,6 +48,11 @@ class RenderTest < Test::Unit::TestCase
get :calling_from_controller_with_params
assert_equal "David of the House, speaking", @response.body
end
+
+ def test_calling_from_controller_with_different_status_code
+ get :calling_from_controller_with_different_status_code
+ assert_equal 500, @response.response_code
+ end
def test_calling_from_template
get :calling_from_template