From a8704c6baa369caea07fae29c449cbabeab43abf Mon Sep 17 00:00:00 2001 From: Simon Jefford Date: Thu, 5 Mar 2009 21:28:02 +0000 Subject: [PATCH] Ensure that loading metals from the main app and engines works on older Ruby versions --- railties/lib/rails/rack/metal.rb | 8 +++++--- railties/test/metal_test.rb | 9 +++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb index bce59f4..78b8a01 100644 --- a/railties/lib/rails/rack/metal.rb +++ b/railties/lib/rails/rack/metal.rb @@ -15,9 +15,11 @@ module Rails metal_glob = metal_paths.map{ |base| "#{base}/**/*.rb" } all_metals = {} - Dir[*metal_glob].sort.map do |file| - file = file.match(matcher)[1] - all_metals[file.classify] = file + metal_glob.each do |glob| + Dir[glob].sort.map do |file| + file = file.match(matcher)[1] + all_metals[file.classify] = file + end end load_list = requested_metals || all_metals.keys diff --git a/railties/test/metal_test.rb b/railties/test/metal_test.rb index a31f4ab..143efdd 100644 --- a/railties/test/metal_test.rb +++ b/railties/test/metal_test.rb @@ -41,6 +41,15 @@ class MetalTest < Test::Unit::TestCase end end + def test_metal_finding_should_work_with_multiple_metal_paths_in_185_and_below + use_appdir("singlemetal") do + engine_metal_path = "#{File.dirname(__FILE__)}/fixtures/plugins/engines/engine/app/metal" + Rails::Rack::Metal.metal_paths << engine_metal_path + $LOAD_PATH << engine_metal_path + assert_equal(["FooMetal", "EngineMetal"], found_metals_as_string_array) + end + end + private def use_appdir(root) -- 1.6.0.4