1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Tests and tweaks for components

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@706 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-02-19 23:51:59 +00:00
parent 0011116592
commit cf6d77600a
2 changed files with 14 additions and 1 deletions

View file

@ -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

View file

@ -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
@ -21,6 +25,10 @@ class CalleeController < ActionController::Base
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
@ -41,6 +49,11 @@ class RenderTest < Test::Unit::TestCase
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
assert_equal "Ring, ring: Lady of the House, speaking", @response.body