Skip to content
This repository
Browse code

Print out information about whether the identity map is on or off whe…

…n running unit tests
  • Loading branch information...
commit 4b371b602b61cae5c3eed0ed6a5a2b0f92e4bbaf 1 parent e488299
Jon Leighton authored June 09, 2011
7  activerecord/RUNNING_UNIT_TESTS
@@ -25,3 +25,10 @@ You can run all the tests for a given database via rake:
25 25
   $ rake test_mysql
26 26
 
27 27
 The 'rake test' task will run all the tests for mysql, mysql2, sqlite3 and postgresql.
  28
+
  29
+== Identity Map
  30
+
  31
+By default the tests run with the Identity Map turned off. But all tests should pass whether or
  32
+not the identity map is on or off. You can turn it on using the IM env variable:
  33
+
  34
+  $ IM=true ruby -Itest test/case/base_test.rb
11  activerecord/test/cases/helper.rb
@@ -12,19 +12,20 @@
12 12
 require 'support/config'
13 13
 require 'support/connection'
14 14
 
15  
-ARTest.connect
16  
-
17 15
 # TODO: Move all these random hacks into the ARTest namespace and into the support/ dir
18 16
 
19 17
 # Show backtraces for deprecated behavior for quicker cleanup.
20 18
 ActiveSupport::Deprecation.debug = true
21 19
 
22  
-# Quote "type" if it's a reserved word for the current connection.
23  
-QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type')
24  
-
25 20
 # Enable Identity Map only when ENV['IM'] is set to "true"
26 21
 ActiveRecord::IdentityMap.enabled = (ENV['IM'] == "true")
27 22
 
  23
+# Connect to the database
  24
+ARTest.connect
  25
+
  26
+# Quote "type" if it's a reserved word for the current connection.
  27
+QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type')
  28
+
28 29
 def current_adapter?(*types)
29 30
   types.any? do |type|
30 31
     ActiveRecord::ConnectionAdapters.const_defined?(type) &&
2  activerecord/test/support/connection.rb
@@ -11,7 +11,7 @@ def self.connection_config
11 11
   end
12 12
 
13 13
   def self.connect
14  
-    puts "Using #{connection_name}"
  14
+    puts "Using #{connection_name} with Identity Map #{ActiveRecord::IdentityMap.enabled? ? 'on' : 'off'}"
15 15
     ActiveRecord::Base.logger = Logger.new("debug.log")
16 16
     ActiveRecord::Base.configurations = connection_config
17 17
     ActiveRecord::Base.establish_connection 'arunit'

0 notes on commit 4b371b6

Please sign in to comment.
Something went wrong with that request. Please try again.