aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/test_case.rb
diff options
context:
space:
mode:
authorDavid Chelimsky <dchelimsky@gmail.com>2010-10-02 12:35:17 -0500
committerSantiago Pastorino <santiago@wyeworks.com>2010-10-03 13:30:31 -0200
commitf656796d05715174568536cfe119a3959a020f23 (patch)
tree4172a679622123335442ef51c9a62d57d3605301 /actionpack/lib/action_view/test_case.rb
parent49cc01002e82208596439bb94d04805b85b75d8d (diff)
downloadrails-f656796d05715174568536cfe119a3959a020f23.tar.gz
rails-f656796d05715174568536cfe119a3959a020f23.tar.bz2
rails-f656796d05715174568536cfe119a3959a020f23.zip
Rename _assigns to view_assigns in AV::TC
- also add tests - also deprecate _assigns [#5751 state:resolved] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'actionpack/lib/action_view/test_case.rb')
-rw-r--r--actionpack/lib/action_view/test_case.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 0eb4a663de..ac59c16d7c 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -103,7 +103,7 @@ module ActionView
end
def render(options = {}, local_assigns = {}, &block)
- view.assign(_assigns)
+ view.assign(view_assigns)
@rendered << output = view.render(options, local_assigns, &block)
output
end
@@ -169,15 +169,19 @@ module ActionView
alias_method :_view, :view
- EXCLUDE_IVARS = %w{
+ INTERNAL_IVARS = %w{
+ @__name__
@_assertion_wrapped
+ @_assertions
@_result
+ @_routes
@controller
@layouts
@locals
@method_name
@output_buffer
@partials
+ @passed
@rendered
@request
@routes
@@ -187,18 +191,26 @@ module ActionView
@view_context_class
}
- def _instance_variables
- instance_variables.map(&:to_s) - EXCLUDE_IVARS
+ def _user_defined_ivars
+ instance_variables.map(&:to_s) - INTERNAL_IVARS
end
- def _assigns
- _instance_variables.inject({}) do |hash, var|
- name = var[1..-1].to_sym
- hash[name] = instance_variable_get(var)
- hash
+ # Returns a Hash of instance variables and their values, as defined by
+ # the user in the test case, which are then assigned to the view being
+ # rendered. This is generally intended for internal use and extension
+ # frameworks.
+ def view_assigns
+ _user_defined_ivars.inject({}) do |hash, var|
+ hash.merge(var.sub('@','').to_sym => instance_variable_get(var))
end
end
+ def _assigns
+ ActiveSupport::Deprecation.warn "ActionView::TestCase#_assigns is deprecated and will be removed in future versions. " <<
+ "Please use view_assigns instead."
+ view_assigns
+ end
+
def _routes
@controller._routes if @controller.respond_to?(:_routes)
end