diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 10105da3e2..63e69accbc 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -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 diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 999a551808..581b08d659 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -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: diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index e9c7ee67e1..77e9d5be26 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -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 -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 diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb index 403bb8f9d5..f18f3682de 100755 --- a/actionpack/test/controller/redirect_test.rb +++ b/actionpack/test/controller/redirect_test.rb @@ -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