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

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
This commit is contained in:
Jamis Buck 2005-07-31 12:16:21 +00:00
parent 020ed6fa1f
commit 08ebab5d20
4 changed files with 32 additions and 1 deletions

View file

@ -1,5 +1,7 @@
*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

View file

@ -11,6 +11,15 @@ module ActionController #:nodoc:
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:

View file

@ -135,6 +135,11 @@ class NewRenderTestController < ActionController::Base
# 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 @@ class NewRenderTest < Test::Unit::TestCase
get :partial_collection_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body
end
def test_render_text_with_assigns
get :render_text_with_assigns
assert_equal "world", assigns["hello"]
end
end

View file

@ -17,6 +17,11 @@ class RedirectController < ActionController::Base
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 @@ class RedirectTest < Test::Unit::TestCase
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