mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Subscriber should not explode if a non namespaced instrumentation is given.
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user