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

Subscriber should not explode if a non namespaced instrumentation is given.

This commit is contained in:
José Valim 2010-02-16 21:37:30 +01:00
parent f0523f72b4
commit 01cd9d66ed
2 changed files with 9 additions and 2 deletions

View file

@ -60,8 +60,9 @@ module Rails
def self.dispatch(args)
namespace, name = args[0].split(".")
log_subscriber = log_subscribers[namespace.to_sym]
return unless namespace && name
log_subscriber = log_subscribers[namespace.to_sym]
if log_subscriber.respond_to?(name) && log_subscriber.logger
begin
log_subscriber.send(name, ActiveSupport::Notifications::Event.new(*args))

View file

@ -79,7 +79,7 @@ class SyncLogSubscriberTest < ActiveSupport::TestCase
Rails::LogSubscriber.add :my_log_subscriber, @log_subscriber
instrument "my_log_subscriber.unknown_event"
wait
# If we get here, it means that NoMethodError was raised.
# If we get here, it means that NoMethodError was not raised.
end
def test_does_not_send_the_event_if_logger_is_nil
@ -90,6 +90,12 @@ class SyncLogSubscriberTest < ActiveSupport::TestCase
wait
end
def test_does_not_fail_with_non_namespaced_events
Rails::LogSubscriber.add :my_log_subscriber, @log_subscriber
instrument "whatever"
wait
end
def test_flushes_loggers
Rails::LogSubscriber.add :my_log_subscriber, @log_subscriber
Rails::LogSubscriber.flush_all!