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:
parent
f0523f72b4
commit
01cd9d66ed
2 changed files with 9 additions and 2 deletions
|
@ -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!
|
||||
|
|
Loading…
Reference in a new issue