Add #concat to Rails::Application::Path

This commit is contained in:
Carl Lerche
2009-06-30 13:55:11 -07:00
parent f281745056
commit 132e6d0063
3 changed files with 12 additions and 1 deletions

View File

@@ -76,7 +76,7 @@ module Rails
@paths.config.locales = "config/locales"
@paths.config.environments = "config/environments"
builtin_directories.each { |dir| @paths.app.controllers << dir }
@paths.app.controllers.concat builtin_directories
@paths.app.load_path!
@paths.app.metals.load_path!

View File

@@ -80,6 +80,10 @@ module Rails
@paths.unshift path
end
def concat(paths)
@paths.concat paths
end
def load_once!
@load_once = true
@root.load_once.push *self.paths

View File

@@ -52,6 +52,12 @@ class PathsTest < ActiveSupport::TestCase
assert_equal ["/app", "/app2"], @root.app.to_a
end
test "adding multiple physical paths using concat" do
@root.app = "/app"
@root.app.concat ["/app2", "/app3"]
assert_equal ["/app", "/app2", "/app3"], @root.app.to_a
end
test "adding multiple physical paths using #unshift" do
@root.app = "/app"
@root.app.unshift "/app2"
@@ -62,6 +68,7 @@ class PathsTest < ActiveSupport::TestCase
assert_raise(RuntimeError) { Rails::Application::Root.new(["/fiz", "/biz"]) }
assert_raise(NoMethodError) { @root.push "/biz" }
assert_raise(NoMethodError) { @root.unshift "/biz" }
assert_raise(NoMethodError) { @root.concat ["/biz"]}
assert_raise(NoMethodError) { @root << "/biz" }
end