Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 5302

Show
Ignore:
Timestamp:
10/14/06 20:27:29 (2 years ago)
Author:
ulysses
Message:

Rename overlapping test names

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/dependencies.rb

    r5053 r5302  
    3939  self.autoloaded_constants = [] 
    4040   
     41  # An array of constant names that need to be unloaded on every request. Used 
     42  # to allow arbitrary constants to be marked for unloading. 
     43  mattr_accessor :explicitly_unloadable_constants 
     44  self.explicitly_unloadable_constants = [] 
     45   
    4146  # Set to true to enable logging of const_missing and file loads 
    4247  mattr_accessor :log_activity 
     
    6166    log_call 
    6267    loaded.clear 
    63     remove_autoloaded_constants! 
     68    remove_unloadable_constants! 
    6469  end 
    6570 
     
    253258  end 
    254259   
    255   # Remove the constants that have been autoloaded. 
    256   def remove_autoloaded_constants! 
    257     until autoloaded_constants.empty? 
    258       const = autoloaded_constants.shift 
    259       next unless qualified_const_defined? const 
    260       names = const.split('::') 
    261       if names.size == 1 || names.first.empty? # It's under Object 
    262         parent = Object 
    263       else 
    264         parent = (names[0..-2] * '::').constantize 
    265       end 
    266       log "removing constant #{const}" 
    267       parent.send :remove_const, names.last 
    268       true 
    269     end 
     260  # Remove the constants that have been autoloaded, and those that have been 
     261  # marked for unloading. 
     262  def remove_unloadable_constants! 
     263    autoloaded_constants.each { |const| remove_constant const } 
     264    autoloaded_constants.clear 
     265    explicitly_unloadable_constants.each { |const| remove_constant const } 
    270266  end 
    271267   
     
    275271    return false unless qualified_const_defined? name 
    276272    return autoloaded_constants.include?(name) 
     273  end 
     274   
     275  # Will the provided constant descriptor be unloaded? 
     276  def will_unload?(const_desc) 
     277    autoloaded?(desc) || 
     278      explicitly_unloadable_constants.include?(const_desc.to_constant_name) 
     279  end 
     280   
     281  # Mark the provided constant name for unloading. This constant will be 
     282  # unloaded on each request, not just the next one. 
     283  def mark_for_unload(const_desc) 
     284    name = const_desc.to_constant_name 
     285    unless explicitly_unloadable_constants.include? name 
     286      explicitly_unloadable_constants << name 
     287    end 
    277288  end 
    278289   
     
    299310      else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}" 
    300311    end 
     312  end 
     313   
     314  def remove_constant(const) 
     315    return false unless qualified_const_defined? const 
     316     
     317    names = const.split('::') 
     318    if names.size == 1 || names.first.empty? # It's under Object 
     319      parent = Object 
     320    else 
     321      parent = (names[0..-2] * '::').constantize 
     322    end 
     323     
     324    log "removing constant #{const}" 
     325    parent.send :remove_const, names.last 
     326    return true 
    301327  end 
    302328   
  • trunk/activesupport/test/class_inheritable_attributes_test.rb

    r5218 r5302  
    154154  end 
    155155   
    156   def test_array_inheritance 
     156  def test_array_inheritance_ 
    157157    @klass.class_inheritable_accessor :a 
    158158    @klass.a = {}