public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Initializer to sort files before eager loading. [#859 state:resolved]

Changed Rails::Initializer to sort files before eager loading them. This ensures 
that
any files in a parent directory will be loaded before files in a subdirectory of 
the
'same' name. i.e. zoo.rb will be loaded before zoo/reptile_house.rb

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
tomafro (author)
Tue Aug 19 05:19:41 -0700 2008
lifo (committer)
Fri Aug 22 05:06:34 -0700 2008
commit  89d1c77dd012f087c091e0f23874c582ea4e3703
tree    94732218057b59da6eff36a7fadbfada9248c816
parent  683ff235e6b81d28962f5a71ff53730a1c118fc8
...
356
357
358
359
 
360
361
362
...
356
357
358
 
359
360
361
362
0
@@ -356,7 +356,7 @@ Run `rake gems:install` to install the missing gems.
0
       if configuration.cache_classes
0
         configuration.eager_load_paths.each do |load_path|
0
           matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/
0
-          Dir.glob("#{load_path}/**/*.rb").each do |file|
0
+          Dir.glob("#{load_path}/**/*.rb").sort.each do |file|
0
             require_dependency file.sub(matcher, '\1')
0
           end
0
         end
...
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
34
35
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
0
@@ -30,6 +30,24 @@ class Initializer_load_environment_Test < Test::Unit::TestCase
0
 
0
 end
0
 
0
+class Initializer_eager_loading_Test < Test::Unit::TestCase
0
+  def setup
0
+    @config = ConfigurationMock.new("")
0
+    @config.cache_classes = true
0
+    @config.load_paths = [File.expand_path(File.dirname(__FILE__) + "/fixtures/eager")]
0
+    @config.eager_load_paths = [File.expand_path(File.dirname(__FILE__) + "/fixtures/eager")]
0
+    @initializer = Rails::Initializer.new(@config)
0
+    @initializer.set_load_path
0
+    @initializer.set_autoload_paths
0
+  end
0
+
0
+  def test_eager_loading_loads_parent_classes_before_children
0
+    assert_nothing_raised do
0
+      @initializer.load_application_classes
0
+    end
0
+  end
0
+end
0
+
0
 uses_mocha 'Initializer after_initialize' do
0
   class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase
0
     def setup

Comments