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:
parent
5b26fa4875
commit
25724c664d
2 changed files with 45 additions and 0 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue