aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-07-31 12:16:21 +0000
committerJamis Buck <jamis@37signals.com>2005-07-31 12:16:21 +0000
commit08ebab5d20527d6dd6600445fc5ec280d502596f (patch)
tree3ba3b69baf8333dac30eb30e6cbf08e76dd130f0
parent020ed6fa1fa5f73e5af88e3c9cdff09293e76789 (diff)
downloadrails-08ebab5d20527d6dd6600445fc5ec280d502596f.tar.gz
rails-08ebab5d20527d6dd6600445fc5ec280d502596f.tar.bz2
rails-08ebab5d20527d6dd6600445fc5ec280d502596f.zip
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
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/test_process.rb9
-rw-r--r--actionpack/test/controller/new_render_test.rb12
-rwxr-xr-xactionpack/test/controller/redirect_test.rb10
4 files changed, 32 insertions, 1 deletions
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