Namespace
Methods
- S
- T
-
- teardown,
- test_basic_query_doesnt_log_when_level_is_not_debug,
- test_basic_query_logging,
- test_cached_queries,
- test_cached_queries_doesnt_log_when_level_is_not_debug,
- test_exists_query_logging,
- test_ignore_binds_payload_with_nil_column,
- test_initializes_runtime,
- test_log,
- test_request_notification,
- test_schema_statements_are_ignored
Included Modules
Instance Public methods
set_logger(logger)
Link
setup()
Link
# File activerecord/test/cases/log_subscriber_test.rb, line 25 def setup @old_logger = ActiveRecord::Base.logger @using_identity_map = ActiveRecord::IdentityMap.enabled? ActiveRecord::IdentityMap.enabled = false Developer.primary_key super ActiveRecord::LogSubscriber.attach_to(:active_record) end
teardown()
Link
test_basic_query_doesnt_log_when_level_is_not_debug()
Link
test_basic_query_logging()
Link
# File activerecord/test/cases/log_subscriber_test.rb, line 69 def test_basic_query_logging Developer.all wait assert_equal 1, @logger.logged(:debug).size assert_match(/Developer Load/, @logger.logged(:debug).last) assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last) end
test_cached_queries()
Link
# File activerecord/test/cases/log_subscriber_test.rb, line 85 def test_cached_queries ActiveRecord::Base.cache do Developer.all Developer.all end wait assert_equal 2, @logger.logged(:debug).size assert_match(/CACHE/, @logger.logged(:debug).last) assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last) end
test_cached_queries_doesnt_log_when_level_is_not_debug()
Link
test_exists_query_logging()
Link
# File activerecord/test/cases/log_subscriber_test.rb, line 77 def test_exists_query_logging Developer.exists? 1 wait assert_equal 1, @logger.logged(:debug).size assert_match(/Developer Exists/, @logger.logged(:debug).last) assert_match(/SELECT .*?FROM .?developers.?/i, @logger.logged(:debug).last) end
test_ignore_binds_payload_with_nil_column()
Link
# File activerecord/test/cases/log_subscriber_test.rb, line 61 def test_ignore_binds_payload_with_nil_column event = Struct.new(:duration, :payload) logger = TestDebugLogSubscriber.new logger.sql(event.new(0, :sql => 'hi mom!', :binds => [[nil, 1]])) assert_equal 1, logger.debugs.length end
test_initializes_runtime()
Link
test_log()
Link
test_request_notification()
Link
# File activeresource/test/cases/log_subscriber_test.rb, line 25 def test_request_notification Person.find(1) wait assert_equal 2, @logger.logged(:info).size assert_equal "GET http://37s.sunrise.i:3000/people/1.json", @logger.logged(:info)[0] assert_match(/\-\-\> 200 200 33/, @logger.logged(:info)[1]) end
test_schema_statements_are_ignored()
Link
# File activerecord/test/cases/log_subscriber_test.rb, line 45 def test_schema_statements_are_ignored event = Struct.new(:duration, :payload) logger = TestDebugLogSubscriber.new assert_equal 0, logger.debugs.length logger.sql(event.new(0, { :sql => 'hi mom!' })) assert_equal 1, logger.debugs.length logger.sql(event.new(0, { :sql => 'hi mom!', :name => 'foo' })) assert_equal 2, logger.debugs.length logger.sql(event.new(0, { :sql => 'hi mom!', :name => 'SCHEMA' })) assert_equal 2, logger.debugs.length end