1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/test/application/initializers/notifications_test.rb

44 lines
1 KiB
Ruby
Raw Normal View History

2009-10-09 08:17:08 -04:00
require "isolation/abstract_unit"
module ApplicationTests
class NotificationsTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
2009-10-09 08:17:08 -04:00
def setup
build_app
boot_rails
2010-01-12 11:48:09 -05:00
end
def teardown
teardown_app
end
2010-01-12 11:48:09 -05:00
def instrument(*args, &block)
ActiveSupport::Notifications.instrument(*args, &block)
end
def wait
ActiveSupport::Notifications.notifier.wait
end
test "rails log_subscribers are added" do
2010-01-12 11:48:09 -05:00
add_to_config <<-RUBY
config.colorize_logging = false
RUBY
require "#{app_path}/config/environment"
require "active_support/log_subscriber/test_helper"
2010-01-12 11:48:09 -05:00
logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new
ActiveRecord::Base.logger = logger
2010-01-12 11:48:09 -05:00
# Mimic Active Record notifications
instrument "sql.active_record", :name => "SQL", :sql => "SHOW tables"
2010-01-12 11:48:09 -05:00
wait
assert_equal 1, logger.logged(:debug).size
assert_match(/SHOW tables/, logger.logged(:debug).last)
2010-01-12 11:48:09 -05:00
end
2009-10-09 08:17:08 -04:00
end
end