diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/railtie.rb | 7 | ||||
-rw-r--r-- | railties/test/railties/railtie_test.rb | 24 |
2 files changed, 31 insertions, 0 deletions
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 2b68a3c453..c76bc83377 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -191,6 +191,13 @@ module Rails def load_tasks self.class.rake_tasks.each(&:call) + + # load also tasks from all superclasses + klass = self.class.superclass + while klass.respond_to?(:rake_tasks) + klass.rake_tasks.each { |t| self.instance_exec(&t) } + klass = klass.superclass + end end def load_generators diff --git a/railties/test/railties/railtie_test.rb b/railties/test/railties/railtie_test.rb index 406d5d764f..6d194eecba 100644 --- a/railties/test/railties/railtie_test.rb +++ b/railties/test/railties/railtie_test.rb @@ -103,6 +103,30 @@ module RailtiesTest assert $ran_block end + test "rake_tasks block defined in superclass of railtie is also executed" do + $ran_block = [] + + class Rails::Railtie + rake_tasks do + $ran_block << railtie_name + end + end + + class MyTie < Rails::Railtie + railtie_name "my_tie" + end + + require "#{app_path}/config/environment" + + assert_equal [], $ran_block + require 'rake' + require 'rake/testtask' + require 'rake/rdoctask' + + AppTemplate::Application.load_tasks + assert $ran_block.include?("my_tie") + end + test "generators block is executed when MyApp.load_generators is called" do $ran_block = false |