Permalink
Browse files

Merge pull request #7587 from elia/fix-too-eager-loading

Should not eager_load app/assets
Conflicts:
	railties/CHANGELOG.md
  • Loading branch information...
1 parent 71abfa5 commit 3663057518eb9acf9b1e72f47dcb07038e6b7368 @rafaelfranca rafaelfranca committed Oct 29, 2012
Showing with 17 additions and 6 deletions.
  1. +2 −0 railties/CHANGELOG.md
  2. +12 −6 railties/lib/rails/paths.rb
  3. +3 −0 railties/test/application/paths_test.rb
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Don't eager-load app/assets and app/views *Elia Schito*
+
* Add `.rake` to list of file extensions included by `rake notes` and `rake notes:custom`. *Brent J. Nordquist*
* New test locations `test/models`, `test/helpers`, `test/controllers`, and
@@ -99,14 +99,15 @@ def load_paths
protected
def filter_by(constraint)
- all = []
+ yes = []
+ no = []
+
all_paths.each do |path|
- if path.send(constraint)
- paths = path.existent
- paths -= path.children.map { |p| p.send(constraint) ? [] : p.existent }.flatten
- all.concat(paths)
- end
+ paths = path.existent + path.existent_base_paths
+ path.send(constraint) ? yes.concat(paths) : no.concat(paths)
end
+
+ all = yes - no
all.uniq!
all
end
@@ -134,6 +135,7 @@ def children
keys.delete(@current)
@root.values_at(*keys.sort)
end
+ deprecate :children
def first
expanded.first
@@ -210,6 +212,10 @@ def existent_directories
expanded.select { |d| File.directory?(d) }
end
+ def existent_base_paths
+ map { |p| File.expand_path(p, @root.path) }.select{ |f| File.exist? f }
+ end
+
alias to_a expanded
end
end
@@ -59,6 +59,8 @@ def assert_not_in_load_path(*path)
assert eager_load.include?(root("app/controllers"))
assert eager_load.include?(root("app/helpers"))
assert eager_load.include?(root("app/models"))
+ assert !eager_load.include?(root("app/views")), "expected to not be in the eager_load_path"
+ assert !eager_load.include?(root("app/assets")), "expected to not be in the eager_load_path"
end
test "environments has a glob equal to the current environment" do
@@ -73,6 +75,7 @@ def assert_not_in_load_path(*path)
assert_in_load_path "vendor"
assert_not_in_load_path "app", "views"
+ assert_not_in_load_path "app", "assets"
assert_not_in_load_path "config"
assert_not_in_load_path "config", "locales"
assert_not_in_load_path "config", "environments"

0 comments on commit 3663057

Please sign in to comment.