diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-29 06:02:16 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-29 06:02:16 -0700 |
commit | a53e46406ea409c2d652a24ff5ecf096e293c8c9 (patch) | |
tree | 243df579be1f25076e54980dbce41c2077bf42fd /railties | |
parent | d40309a0b8faaea766f8cf89b36d2323a1d35d88 (diff) | |
parent | f7de647f2cd099ecf6434fa4a0db1ec297f1c32d (diff) | |
download | rails-a53e46406ea409c2d652a24ff5ecf096e293c8c9.tar.gz rails-a53e46406ea409c2d652a24ff5ecf096e293c8c9.tar.bz2 rails-a53e46406ea409c2d652a24ff5ecf096e293c8c9.zip |
Merge pull request #7587 from elia/fix-too-eager-loading
Should not eager_load app/assets
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 2 | ||||
-rw-r--r-- | railties/lib/rails/paths.rb | 18 | ||||
-rw-r--r-- | railties/test/application/paths_test.rb | 3 |
3 files changed, 17 insertions, 6 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 27f4fd6de7..b3b1633089 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 3.2.9 (unreleased) +* Don't eager-load app/assets and app/views *Elia Schito* + * Update supported ruby versions error message in ruby_version_check.rb *Lihan Li* ## Rails 3.2.8 (Aug 9, 2012) ## diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 4ac3d88dc2..c24940816d 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -87,14 +87,15 @@ module Rails 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 @@ -123,6 +124,7 @@ module Rails keys.delete(@current) @root.values_at(*keys.sort) end + deprecate :children def first expanded.first @@ -194,6 +196,10 @@ module Rails 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 private diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb index 964cff48cd..176476f129 100644 --- a/railties/test/application/paths_test.rb +++ b/railties/test/application/paths_test.rb @@ -61,6 +61,8 @@ module ApplicationTests 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 @@ -75,6 +77,7 @@ module ApplicationTests 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" |