aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionmailer/lib/action_mailer/adv_attr_accessor.rb2
-rwxr-xr-xactionpack/lib/action_controller/base.rb2
-rw-r--r--actionpack/lib/action_controller/test_process.rb2
-rw-r--r--actionpack/test/controller/new_render_test.rb1
-rw-r--r--activerecord/test/associations/inner_join_association_test.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/instance_variables.rb4
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb4
7 files changed, 13 insertions, 4 deletions
diff --git a/actionmailer/lib/action_mailer/adv_attr_accessor.rb b/actionmailer/lib/action_mailer/adv_attr_accessor.rb
index cfd723011a..e77029afdd 100644
--- a/actionmailer/lib/action_mailer/adv_attr_accessor.rb
+++ b/actionmailer/lib/action_mailer/adv_attr_accessor.rb
@@ -16,7 +16,7 @@ module ActionMailer
define_method(name) do |*parameters|
raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1
if parameters.empty?
- if instance_variables.include?(ivar)
+ if instance_variable_names.include?(ivar)
instance_variable_get(ivar)
end
else
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index ff77e036fb..3818960979 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -1210,7 +1210,7 @@ module ActionController #:nodoc:
def add_instance_variables_to_assigns
@@protected_variables_cache ||= Set.new(protected_instance_variables)
- instance_variables.each do |var|
+ instance_variable_names.each do |var|
next if @@protected_variables_cache.include?(var)
@assigns[var[1..-1]] = instance_variable_get(var)
end
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index 8853311594..4cbb695f4c 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -373,7 +373,7 @@ module ActionController #:nodoc:
# Sanity check for required instance variables so we can give an
# understandable error message.
%w(@controller @request @response).each do |iv_name|
- if !(instance_variables.include?(iv_name) || instance_variables.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
+ if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
raise "#{iv_name} is nil: make sure you set it in your test's setup method."
end
end
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 3168daeaec..4c0b9d0c9c 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -495,6 +495,7 @@ class NewRenderTest < Test::Unit::TestCase
ActionController::Base.protected_variables_cache = nil
get :hello_world
+ assert !assigns.include?('_request'), '_request should not be in assigns'
assert !assigns.include?('request'), 'request should not be in assigns'
ActionController::Base.view_controller_internals = true
diff --git a/activerecord/test/associations/inner_join_association_test.rb b/activerecord/test/associations/inner_join_association_test.rb
index 8d583f2138..d2ba4ef634 100644
--- a/activerecord/test/associations/inner_join_association_test.rb
+++ b/activerecord/test/associations/inner_join_association_test.rb
@@ -67,7 +67,7 @@ class InnerJoinAssociationTest < Test::Unit::TestCase
def test_find_with_implicit_inner_joins_does_not_set_associations
authors = Author.find(:all, :select => 'authors.*', :joins => :posts)
assert !authors.empty?, "expected authors to be non-empty"
- assert authors.all? {|a| !a.send(:instance_variables).include?("@posts")}, "expected no authors to have the @posts association loaded"
+ assert authors.all? {|a| !a.send(:instance_variable_names).include?("@posts")}, "expected no authors to have the @posts association loaded"
end
def test_count_honors_implicit_inner_joins
diff --git a/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
index e07eb76c1d..57276135c4 100644
--- a/activesupport/lib/active_support/core_ext/object/instance_variables.rb
+++ b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
@@ -13,6 +13,10 @@ class Object
end
end
+ def instance_variable_names
+ instance_variables.map(&:to_s)
+ end
+
def copy_instance_variables_from(object, exclude = []) #:nodoc:
exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables
diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb
index f885d94be3..09a86721dd 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -182,6 +182,10 @@ class ObjectInstanceVariableTest < Test::Unit::TestCase
@source.instance_variable_set(:@baz, 'baz')
end
+ def test_instance_variable_names
+ assert_equal %w(@bar @baz), @source.instance_variable_names.sort
+ end
+
def test_instance_variable_defined
assert @source.instance_variable_defined?('@bar')
assert @source.instance_variable_defined?(:@bar)