Index: railties/test/plugin_loader_test.rb =================================================================== --- railties/test/plugin_loader_test.rb (revision 652) +++ railties/test/plugin_loader_test.rb (working copy) @@ -4,6 +4,8 @@ class TestPluginLoader < Test::Unit::TestCase ORIGINAL_LOAD_PATH = $LOAD_PATH.dup + ORIGINAL_DEPENDENCIES_LOAD_PATHS = Dependencies.load_paths.dup + ORIGINAL_DEPENDENCIES_LOAD_ONCE_PATHS = Dependencies.load_once_paths.dup def setup reset_load_path! @@ -119,6 +121,37 @@ assert Dependencies.load_once_paths.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) end + def test_should_add_plugin_load_paths_to_global_LOAD_PATH_array_in_reverse_alphabetical_order + only_load_the_following_plugins! [:acts_as_chunky_bacon, :stubby] + + @loader.add_plugin_load_paths + + stubby_lib_index = $LOAD_PATH.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) + bacon_lib_index = $LOAD_PATH.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) + assert stubby_lib_index < bacon_lib_index + end + + def test_should_add_plugin_load_paths_to_Dependencies_load_paths_array_in_reverse_alphabetical_order + Dependencies.load_paths = [] + only_load_the_following_plugins! [:acts_as_chunky_bacon, :stubby] + + @loader.add_plugin_load_paths + + stubby_lib_index = Dependencies.load_paths.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) + bacon_lib_index = Dependencies.load_paths.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) + assert stubby_lib_index < bacon_lib_index + end + + def test_should_add_plugin_load_paths_to_Dependencies_load_once_paths_array_in_reverse_alphabetical_order + only_load_the_following_plugins! [:acts_as_chunky_bacon, :stubby] + + @loader.add_plugin_load_paths + + stubby_lib_index = Dependencies.load_once_paths.index(File.join(plugin_fixture_path('default/stubby'), 'lib')) + bacon_lib_index = Dependencies.load_once_paths.index(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) + assert stubby_lib_index < bacon_lib_index + end + def test_should_add_all_load_paths_from_a_plugin_to_LOAD_PATH_array plugin_load_paths = ["a", "b"] plugin = stub(:load_paths => plugin_load_paths) @@ -133,7 +166,12 @@ def reset_load_path! $LOAD_PATH.clear - ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path } + Dependencies.load_paths.clear + Dependencies.load_once_paths.clear + + ORIGINAL_LOAD_PATH.each { |path| $LOAD_PATH << path } + ORIGINAL_DEPENDENCIES_LOAD_PATHS.each { |path| Dependencies.load_paths << path } + ORIGINAL_DEPENDENCIES_LOAD_ONCE_PATHS.each { |path| Dependencies.load_once_paths << path } end end