Load deprecated tasks for plugins.

This commit is contained in:
José Valim 2010-01-24 09:47:55 +01:00
parent 5b26fa4875
commit 25724c664d
2 changed files with 45 additions and 0 deletions

View File

@ -23,6 +23,17 @@ module Rails
attr_reader :name, :path attr_reader :name, :path
def load_tasks
super
extra_tasks = Dir["#{root}/{tasks,rails/tasks}/**/*.rake"]
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"
extra_tasks.sort.each { |ext| load(ext) }
end
end
def initialize(root) def initialize(root)
@name = File.basename(root).to_sym @name = File.basename(root).to_sym
config.root = root config.root = root

View File

@ -145,6 +145,40 @@ module PluginsTest
response = Rails.application.call(Rack::MockRequest.env_for("/sprokkit")) response = Rails.application.call(Rack::MockRequest.env_for("/sprokkit"))
assert_equal "I am a Sprokkit", response[2].join assert_equal "I am a Sprokkit", response[2].join
end end
test "tasks are loaded by default" do
$executed = false
@plugin.write "lib/tasks/foo.rake", <<-RUBY
task :foo do
$executed = true
end
RUBY
boot_rails
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
Rails.application.load_tasks
Rake::Task[:foo].invoke
assert $executed
end
test "deprecated tasks are also loaded" do
$executed = false
@plugin.write "tasks/foo.rake", <<-RUBY
task :foo do
$executed = true
end
RUBY
boot_rails
require 'rake'
require 'rake/rdoctask'
require 'rake/testtask'
Rails.application.load_tasks
Rake::Task[:foo].invoke
assert $executed
end
end end
class VendoredOrderingTest < Test::Unit::TestCase class VendoredOrderingTest < Test::Unit::TestCase