Ticket #10630: instance_variable_names.diff
| File instance_variable_names.diff, 5.4 kB (added by fcheung, 1 year ago) |
|---|
-
actionmailer/test/adv_attr_test.rb
old new 1 require File.dirname(__FILE__) + '/abstract_unit' 2 require 'action_mailer/adv_attr_accessor' 3 4 class AdvAttrTest < Test::Unit::TestCase 5 class Person 6 include ActionMailer::AdvAttrAccessor 7 adv_attr_accessor :name 8 end 9 10 def test_adv_attr 11 bob = Person.new 12 assert_nil bob.name 13 bob.name 'Bob' 14 assert_equal 'Bob', bob.name 15 16 assert_raise(ArgumentError) {bob.name 'x', 'y'} 17 end 18 19 20 end -
actionmailer/lib/action_mailer/adv_attr_accessor.rb
old new 16 16 define_method(name) do |*parameters| 17 17 raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1 18 18 if parameters.empty? 19 if instance_variable s.include?(ivar)19 if instance_variable_names.include?(ivar) 20 20 instance_variable_get(ivar) 21 21 end 22 22 else -
activesupport/test/core_ext/object_and_class_ext_test.rb
old new 182 182 @source.instance_variable_set(:@baz, 'baz') 183 183 end 184 184 185 def test_instance_variable_names 186 assert_equal %w(@bar @baz), @source.instance_variable_names.sort 187 end 188 185 189 def test_instance_variable_defined 186 190 assert @source.instance_variable_defined?('@bar') 187 191 assert @source.instance_variable_defined?(:@bar) -
activesupport/lib/active_support/core_ext/object/instance_variables.rb
old new 12 12 values 13 13 end 14 14 end 15 16 def instance_variable_names 17 instance_variables.map(&:to_s) 18 end 15 19 16 20 def copy_instance_variables_from(object, exclude = []) #:nodoc: 17 21 exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables -
activerecord/test/associations/inner_join_association_test.rb
old new 67 67 def test_find_with_implicit_inner_joins_does_not_set_associations 68 68 authors = Author.find(:all, :select => 'authors.*', :joins => :posts) 69 69 assert !authors.empty?, "expected authors to be non-empty" 70 assert authors.all? {|a| !a.send(:instance_variable s).include?("@posts")}, "expected no authors to have the @posts association loaded"70 assert authors.all? {|a| !a.send(:instance_variable_names).include?("@posts")}, "expected no authors to have the @posts association loaded" 71 71 end 72 72 73 73 def test_count_honors_implicit_inner_joins -
actionpack/test/controller/new_render_test.rb
old new 495 495 ActionController::Base.protected_variables_cache = nil 496 496 497 497 get :hello_world 498 assert !assigns.include?('_request'), '_request should not be in assigns' 498 499 assert !assigns.include?('request'), 'request should not be in assigns' 499 500 500 501 ActionController::Base.view_controller_internals = true -
actionpack/lib/action_controller/base.rb
old new 1210 1210 1211 1211 def add_instance_variables_to_assigns 1212 1212 @@protected_variables_cache ||= Set.new(protected_instance_variables) 1213 instance_variable s.each do |var|1213 instance_variable_names.each do |var| 1214 1214 next if @@protected_variables_cache.include?(var) 1215 1215 @assigns[var[1..-1]] = instance_variable_get(var) 1216 1216 end -
actionpack/lib/action_controller/test_process.rb
old new 373 373 # Sanity check for required instance variables so we can give an 374 374 # understandable error message. 375 375 %w(@controller @request @response).each do |iv_name| 376 if !(instance_variable s.include?(iv_name) || instance_variables.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?376 if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil? 377 377 raise "#{iv_name} is nil: make sure you set it in your test's setup method." 378 378 end 379 379 end