diff options
-rw-r--r-- | railties/lib/rails.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/plugin.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/railtie.rb | 4 | ||||
-rw-r--r-- | railties/test/plugins/configuration_test.rb | 9 |
4 files changed, 15 insertions, 0 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index 5f7e595d64..4ded2515fc 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -15,6 +15,7 @@ require 'rails/rack' require 'rails/paths' require 'rails/configuration' require 'rails/deprecation' +require 'rails/subscriber' require 'rails/ruby_version_check' # For Ruby 1.8, this initialization sets $KCODE to 'u' to enable the diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 9cc6b9c35b..a057b8f701 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -53,6 +53,7 @@ module Rails ActionController::Base.view_paths.concat ["#{path}/app/views"] if File.directory?("#{path}/app/views") end + # TODO Isn't it supposed to be :after => "action_controller.initialize_routing" ? initializer :add_routing_file, :after => :initialize_routing do |app| routing_file = "#{path}/config/routes.rb" if File.exist?(routing_file) diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index ff28ade35d..43a0303c5b 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -25,6 +25,10 @@ module Rails Configuration.default end + def self.subscriber(subscriber) + Rails::Subscriber.add(plugin_name, subscriber) + end + def self.rake_tasks(&blk) @rake_tasks ||= [] @rake_tasks << blk if blk diff --git a/railties/test/plugins/configuration_test.rb b/railties/test/plugins/configuration_test.rb index 25bf24eb3b..09f8943af9 100644 --- a/railties/test/plugins/configuration_test.rb +++ b/railties/test/plugins/configuration_test.rb @@ -32,5 +32,14 @@ module PluginsTest assert_equal "hello", MyApp.config.foo.greetings assert_equal "bar", MyApp.config.foo.bar end + + test "plugin can add subscribers" do + begin + class Foo < Rails::Railtie; subscriber(Rails::Subscriber.new); end + assert_kind_of Rails::Subscriber, Rails::Subscriber.subscribers[:foo] + ensure + Rails::Subscriber.subscribers.clear + end + end end end |