diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-11-11 23:36:02 -0800 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-11-11 23:36:02 -0800 |
commit | 98991a98398feae3988be72563c80f808a74ebeb (patch) | |
tree | ce1a8f741855a3d7e0499a5f14637c0838561667 | |
parent | bd004eccfa1b7e6c8e4f1273da94477d75b9515f (diff) | |
parent | ec3134739c6bf7cf6482feb46155293e2b09c45b (diff) | |
download | rails-98991a98398feae3988be72563c80f808a74ebeb.tar.gz rails-98991a98398feae3988be72563c80f808a74ebeb.tar.bz2 rails-98991a98398feae3988be72563c80f808a74ebeb.zip |
Merge pull request #12695 from mikepack/allow_pathnames
Allow Pathnames to be added to eager load paths
-rw-r--r-- | railties/CHANGELOG.md | 4 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 2 | ||||
-rw-r--r-- | railties/test/application/initializers/load_path_test.rb | 14 |
3 files changed, 19 insertions, 1 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 673da4e9be..bf09066cf1 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Support for Pathnames in eager load paths. + + *Mike Pack* + * Fixed missing line and shadow on service pages(404, 422, 500). *Dmitry Korotkov* diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index e8adef2fd3..1296c0a843 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -465,7 +465,7 @@ module Rails # files inside eager_load paths. def eager_load! config.eager_load_paths.each do |load_path| - matcher = /\A#{Regexp.escape(load_path)}\/(.*)\.rb\Z/ + matcher = /\A#{Regexp.escape(load_path.to_s)}\/(.*)\.rb\Z/ Dir.glob("#{load_path}/**/*.rb").sort.each do |file| require_dependency file.sub(matcher, '\1') end diff --git a/railties/test/application/initializers/load_path_test.rb b/railties/test/application/initializers/load_path_test.rb index b36628ee37..cd05956356 100644 --- a/railties/test/application/initializers/load_path_test.rb +++ b/railties/test/application/initializers/load_path_test.rb @@ -71,6 +71,20 @@ module ApplicationTests assert Zoo end + test "eager loading accepts Pathnames" do + app_file "lib/foo.rb", <<-RUBY + module Foo; end + RUBY + + add_to_config <<-RUBY + config.eager_load = true + config.eager_load_paths << Pathname.new("#{app_path}/lib") + RUBY + + require "#{app_path}/config/environment" + assert Foo + end + test "load environment with global" do $initialize_test_set_from_env = nil app_file "config/environments/development.rb", <<-RUBY |