提交 3fc37e8e 编写于 作者: J José Valim

Fix failing AR test.

上级 de916632
require "cases/helper"
require "active_support/log_subscriber/test_helper"
require 'models/developer'
require 'models/project'
......@@ -28,8 +27,6 @@ class IdentityMapTest < ActiveRecord::TestCase
:developers_projects, :computers, :authors, :author_addresses,
:posts, :tags, :taggings, :comments, :subscribers
include ActiveSupport::LogSubscriber::TestHelper
##############################################################################
# Basic tests checking if IM is functioning properly on basic find operations#
##############################################################################
......@@ -386,20 +383,6 @@ def test_find_using_select_and_identity_map
assert_not_nil post.title
end
def test_log
# FIXME: Can't seem to figure out why it isn't logging in test, works fine in a real app
pending "LogSubscriber wonkiness"
@old_logger = ActiveRecord::Base.logger
ActiveRecord::LogSubscriber.attach_to(:active_record)
Post.find 1
Post.find 1
assert_match(/From Identity Map/, @logger.logged(:debug).last)
ensure
ActiveRecord::LogSubscriber.log_subscribers.pop
ActiveRecord::Base.logger = @old_logger
end
# Currently AR is not allowing changing primary key (see Persistence#update)
# So we ignore it. If this changes, this test needs to be uncommented.
# def test_updating_of_pkey
......
require "cases/helper"
require "models/developer"
require "models/post"
require "active_support/log_subscriber/test_helper"
class LogSubscriberTest < ActiveRecord::TestCase
include ActiveSupport::LogSubscriber::TestHelper
include ActiveSupport::BufferedLogger::Severity
fixtures :posts
def setup
@old_logger = ActiveRecord::Base.logger
@using_identity_map = ActiveRecord::IdentityMap.enabled?
......@@ -91,4 +94,13 @@ def test_cached_queries_doesnt_log_when_level_is_not_debug
def test_initializes_runtime
Thread.new { assert_equal 0, ActiveRecord::LogSubscriber.runtime }.join
end
def test_log
ActiveRecord::IdentityMap.use do
Post.find 1
Post.find 1
end
wait
assert_match(/From Identity Map/, @logger.logged(:debug).last)
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册