Permalink
Browse files

Merge pull request #6910 from mulder/fix_path_glob

Persist glob when replacing a path
  • Loading branch information...
2 parents 98b46bf + 0f4d005 commit 2ee3fa1a48513a2c42833e2e1f60fe03769bc295 @josevalim josevalim committed Jul 1, 2012
Showing with 9 additions and 1 deletion.
  1. +2 −1 railties/lib/rails/paths.rb
  2. +7 −0 railties/test/paths_test.rb
View
3 railties/lib/rails/paths.rb
@@ -51,7 +51,8 @@ def initialize(path)
end
def []=(path, value)
- add(path, :with => value)
+ glob = self[path] ? self[path].glob : nil
+ add(path, :with => value, :glob => glob)
end
def add(path, options={})
View
7 railties/test/paths_test.rb
@@ -198,6 +198,13 @@ def setup
assert_equal "*.rb", @root["app"].glob
end
+ test "it should be possible to replace a path and persist the original paths glob" do
+ @root.add "app", :glob => "*.rb"
+ @root["app"] = "app2"
+ assert_equal ["/foo/bar/app2"], @root["app"].paths
+ assert_equal "*.rb", @root["app"].glob
+ end
+
test "a path can be added to the load path" do
@root["app"] = "app"
@root["app"].load_path!

0 comments on commit 2ee3fa1

Please sign in to comment.