mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Show deprecation message for rails/init.rb in plugins.
This commit is contained in:
parent
e8ef12e39d
commit
23fd1f1280
2 changed files with 17 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue