1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
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)
@name = File.basename(root).to_sym
config.root = root

View file

@ -145,6 +145,40 @@ module PluginsTest
response = Rails.application.call(Rack::MockRequest.env_for("/sprokkit"))
assert_equal "I am a Sprokkit", response[2].join
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
class VendoredOrderingTest < Test::Unit::TestCase