提交 f8f4eccd 编写于 作者: S Scott Barron

If a component redirects when called with render_component_as_string, render the

redirected to action.

Fixes #2327


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2604 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 00a194d7
......@@ -38,7 +38,14 @@ def render_component(options = {}) #:doc:
# Returns the component response as a string
def render_component_as_string(options) #:doc:
component_logging(options) { component_response(options, false).body }
component_logging(options) do
response = component_response(options, false)
unless response.redirected_to.nil?
render_component_as_string response.redirected_to
else
response.body
end
end
end
private
......
......@@ -26,11 +26,19 @@ def internal_callee
end
def set_flash
render_component(:controller => 'callee', :action => 'set_flash')
render_component(:controller => "callee", :action => "set_flash")
end
def use_flash
render_component(:controller => 'callee', :action => 'use_flash')
render_component(:controller => "callee", :action => "use_flash")
end
def calling_redirected
render_component(:controller => "callee", :action => "redirected")
end
def calling_redirected_as_string
render_template "<%= render_component(:controller => 'callee', :action => 'redirected') %>"
end
def rescue_action(e) raise end
......@@ -53,6 +61,10 @@ def set_flash
def use_flash
render :text => flash[:notice] || 'no flash'
end
def redirected
redirect_to :controller => "callee", :action => "being_called"
end
def rescue_action(e) raise end
end
......@@ -97,4 +109,16 @@ def test_flash
get :use_flash
assert_equal 'no flash', @response.body
end
def test_component_redirect_redirects
get :calling_redirected
assert_redirected_to :action => "being_called"
end
def test_component_as_string_redirect_renders_redirecte_action
get :calling_redirected_as_string
assert_equal "Lady of the House, speaking", @response.body
end
end
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册