Permalink
Browse files

Fix failing AR test.

  • Loading branch information...
1 parent de91663 commit 3fc37e8ef96b3f139427189b58c426ec7fff65be @josevalim josevalim committed May 2, 2011
Showing with 12 additions and 17 deletions.
  1. +0 −17 activerecord/test/cases/identity_map_test.rb
  2. +12 −0 activerecord/test/cases/log_subscriber_test.rb
@@ -1,5 +1,4 @@
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
@@ -1,11 +1,14 @@
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

0 comments on commit 3fc37e8

Please sign in to comment.