aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/lib/rails/plugin.rb10
-rw-r--r--railties/test/railties/plugin_test.rb9
2 files changed, 17 insertions, 2 deletions
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index 64d03e7599..882f2dc28e 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -29,7 +29,7 @@ module Rails
unless extra_tasks.empty?
ActiveSupport::Deprecation.warn "Having rake tasks in PLUGIN_PATH/tasks or " <<
- "PLUGIN_PATH/rails/tasks is deprecated. Use to PLUGIN_PATH/lib/tasks instead"
+ "PLUGIN_PATH/rails/tasks is deprecated. Use PLUGIN_PATH/lib/tasks instead"
extra_tasks.sort.each { |ext| load(ext) }
end
end
@@ -44,7 +44,13 @@ module Rails
end
initializer :load_init_rb, :before => :load_application_initializers do |app|
- file = Dir["#{root}/{rails/init,init}.rb"].first
+ if File.file?(file = File.expand_path("rails/init.rb", root))
+ ActiveSupport::Deprecation.warn "PLUGIN_PATH/rails/init.rb in plugins is deprecated. " <<
+ "Use PLUGIN_PATH/init.rb instead"
+ else
+ file = File.expand_path("init.rb", root)
+ end
+
config = app.config
eval(File.read(file), binding, file) if file && File.file?(file)
end
diff --git a/railties/test/railties/plugin_test.rb b/railties/test/railties/plugin_test.rb
index 09b859dcdd..0f5f29468c 100644
--- a/railties/test/railties/plugin_test.rb
+++ b/railties/test/railties/plugin_test.rb
@@ -94,6 +94,15 @@ module RailtiesTest
assert rescued, "Expected boot rails to fail"
end
+ test "loads deprecated rails/init.rb" do
+ @plugin.write "rails/init.rb", <<-RUBY
+ $loaded = true
+ RUBY
+
+ boot_rails
+ assert $loaded
+ end
+
test "deprecated tasks are also loaded" do
$executed = false
@plugin.write "tasks/foo.rake", <<-RUBY