Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added assigns shortcut for @response.template.assigns to controller t…

…est cases [bitsweat]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@881 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 651ea0d39c5c766ffb2abc8330fd6c6f88125720 1 parent 7ece0e1
@dhh dhh authored
View
16 actionpack/CHANGELOG
@@ -1,5 +1,21 @@
*SVN*
+* Added assigns shortcut for @response.template.assigns to controller test cases [bitsweat]. Example:
+
+ Before:
+
+ def test_list
+ assert_equal 5, @response.template.assigns['recipes'].size
+ assert_equal 8, @response.template.assigns['categories'].size
+ end
+
+ After:
+
+ def test_list
+ assert_equal 5, assigns(:recipes).size
+ assert_equal 8, assigns(:categories).size
+ end
+
* Added TagHelper#image_tag and deprecated UrlHelper#link_image_to (recommended approach is to combine image_tag and link_to instead)
* Fixed textilize to be resilient to getting nil parsed (by using Object#blank? instead of String#empty?)
View
6 actionpack/lib/action_controller/test_process.rb
@@ -277,6 +277,10 @@ def follow_redirect
get(@response.redirected_to.delete(:action), @response.redirected_to.stringify_keys)
end
- end
+
+ def assigns(name)
+ @response.template.assigns[name.to_s]
+ end
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.