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

Changeset 4730

Show
Ignore:
Timestamp:
08/08/06 22:08:09 (2 years ago)
Author:
ulysses
Message:

Add forgotten files; Fix double loading errors.

Files:

Legend:

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

    r4729 r4730  
    5252  def require_or_load(file_name, const_path = nil) 
    5353    file_name = $1 if file_name =~ /^(.*)\.rb$/ 
    54     return if loaded.include?(file_name) 
     54    expanded = File.expand_path(file_name) 
     55    return if loaded.include?(expanded) 
    5556 
    5657    # Record that we've seen this file *before* loading it to avoid an 
    5758    # infinite loop with mutual dependencies. 
    58     loaded << file_name 
     59    loaded << expanded 
    5960 
    6061    if load? 
     
    6566        load_args << const_path unless const_path.nil? 
    6667         
    67         if !warnings_on_first_load or history.include?(file_name
     68        if !warnings_on_first_load or history.include?(expanded
    6869          load_file(*load_args) 
    6970        else 
     
    7172        end 
    7273      rescue 
    73         loaded.delete file_name 
     74        loaded.delete expanded 
    7475        raise 
    7576      end 
     
    7980 
    8081    # Record history *after* loading so first load gets warnings. 
    81     history << file_name 
     82    history << expanded 
    8283  end 
    8384   
     
    156157     
    157158    file_path = search_for_autoload_file(path_suffix) 
    158     if file_path #&& ! loaded.include?(file_path) # We found a matching file to load 
     159    if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load 
    159160      require_or_load file_path, qualified_name 
    160161      raise LoadError, "Expected #{file_path} to define #{qualified_name}" unless from_mod.const_defined?(const_name) 
  • trunk/activesupport/test/dependencies_test.rb

    r4729 r4730  
    5858 
    5959      filename = "#{File.dirname(__FILE__)}/dependencies/check_warnings" 
     60      expanded = File.expand_path(filename) 
    6061      $check_warnings_load_count = 0 
    6162 
    62       assert !Dependencies.loaded.include?(filename
    63       assert !Dependencies.history.include?(filename
     63      assert !Dependencies.loaded.include?(expanded
     64      assert !Dependencies.history.include?(expanded
    6465 
    6566      silence_warnings { require_dependency filename } 
     
    6768      assert_equal true, $checked_verbose, 'On first load warnings should be enabled.' 
    6869 
    69       assert Dependencies.loaded.include?(filename
     70      assert Dependencies.loaded.include?(expanded
    7071      Dependencies.clear 
    71       assert !Dependencies.loaded.include?(filename
    72       assert Dependencies.history.include?(filename
     72      assert !Dependencies.loaded.include?(expanded
     73      assert Dependencies.history.include?(expanded
    7374 
    7475      silence_warnings { require_dependency filename } 
     
    7677      assert_equal nil, $checked_verbose, 'After first load warnings should be left alone.' 
    7778 
    78       assert Dependencies.loaded.include?(filename
     79      assert Dependencies.loaded.include?(expanded
    7980      Dependencies.clear 
    80       assert !Dependencies.loaded.include?(filename
    81       assert Dependencies.history.include?(filename
     81      assert !Dependencies.loaded.include?(expanded
     82      assert Dependencies.history.include?(expanded
    8283 
    8384      enable_warnings { require_dependency filename } 
     
    8586      assert_equal true, $checked_verbose, 'After first load warnings should be left alone.' 
    8687 
    87       assert Dependencies.loaded.include?(filename
     88      assert Dependencies.loaded.include?(expanded
    8889    end 
    8990  end 
     
    303304  def test_const_missing_should_not_double_load 
    304305    with_loading 'autoloading_fixtures' do 
    305       require_dependency 'counting_loader' 
     306      require_dependency '././counting_loader' 
    306307      assert_equal 1, $counting_loaded_times 
    307       ModuleFolder 
     308      Dependencies.load_missing_constant Object, :CountingLoader 
    308309      assert_equal 1, $counting_loaded_times 
    309310    end