提交 08ebab5d 编写于 作者: J Jamis Buck

Make sure assigns are built for every request when testing #1866


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1961 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 020ed6fa
*SVN*
* Make sure assigns are built for every request when testing #1866
* Allow remote_addr to be queried on TestRequest #1668
* Fixed bug when a partial render was passing a local with the same name as the partial
......
......@@ -11,6 +11,15 @@ def self.process_test(request)
def process_test(request) #:nodoc:
process(request, TestResponse.new)
end
def process_with_test(*args)
returning process_without_test(*args) do
add_variables_to_assigns
end
end
alias_method :process_without_test, :process
alias_method :process, :process_with_test
end
class TestRequest < AbstractRequest #:nodoc:
......
......@@ -135,6 +135,11 @@ def action_talk_to_layout
# Action template sets variable that's picked up by layout
end
def render_text_with_assigns
@hello = "world"
render :text => "foo"
end
def rescue_action(e) raise end
private
......@@ -342,4 +347,9 @@ def test_partial_collection_with_locals
get :partial_collection_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body
end
end
\ No newline at end of file
def test_render_text_with_assigns
get :render_text_with_assigns
assert_equal "world", assigns["hello"]
end
end
......@@ -17,6 +17,11 @@ def module_redirect
redirect_to :controller => 'module_test/module_redirect', :action => "hello_world"
end
def redirect_with_assigns
@hello = "world"
redirect_to :action => "hello_world"
end
def rescue_errors(e) raise e end
protected
......@@ -56,6 +61,11 @@ def test_module_redirect_using_options
get :module_redirect
assert_redirected_to :controller => 'module_test/module_redirect', :action => 'hello_world'
end
def test_redirect_with_assigns
get :redirect_with_assigns
assert_equal "world", assigns["hello"]
end
end
module ModuleTest
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册