Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 08ebab5d20527d6dd6600445fc5ec280d502596f 1 parent 020ed6f
@jamis jamis authored
View
2  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
View
9 actionpack/lib/action_controller/test_process.rb
@@ -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:
View
12 actionpack/test/controller/new_render_test.rb
@@ -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
+
+ def test_render_text_with_assigns
+ get :render_text_with_assigns
+ assert_equal "world", assigns["hello"]
+ end
+end
View
10 actionpack/test/controller/redirect_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.