aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG16
-rw-r--r--actionpack/lib/action_controller/test_process.rb6
2 files changed, 21 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 53cd36f611..cc1d9c8297 100644
--- a/actionpack/CHANGELOG
+++ b/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?)
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 3223da198c..e3ab045a12 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -277,6 +277,10 @@ module Test
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 \ No newline at end of file