1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Print out information about whether the identity map is on or off when running unit tests

This commit is contained in:
Jon Leighton 2011-06-09 20:15:34 +01:00
parent e48829946d
commit 4b371b602b
3 changed files with 14 additions and 6 deletions

View file

@ -25,3 +25,10 @@ You can run all the tests for a given database via rake:
$ rake test_mysql
The 'rake test' task will run all the tests for mysql, mysql2, sqlite3 and postgresql.
== Identity Map
By default the tests run with the Identity Map turned off. But all tests should pass whether or
not the identity map is on or off. You can turn it on using the IM env variable:
$ IM=true ruby -Itest test/case/base_test.rb

View file

@ -12,19 +12,20 @@ require 'active_support/dependencies'
require 'support/config'
require 'support/connection'
ARTest.connect
# TODO: Move all these random hacks into the ARTest namespace and into the support/ dir
# Show backtraces for deprecated behavior for quicker cleanup.
ActiveSupport::Deprecation.debug = true
# Quote "type" if it's a reserved word for the current connection.
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type')
# Enable Identity Map only when ENV['IM'] is set to "true"
ActiveRecord::IdentityMap.enabled = (ENV['IM'] == "true")
# Connect to the database
ARTest.connect
# Quote "type" if it's a reserved word for the current connection.
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type')
def current_adapter?(*types)
types.any? do |type|
ActiveRecord::ConnectionAdapters.const_defined?(type) &&

View file

@ -11,7 +11,7 @@ module ARTest
end
def self.connect
puts "Using #{connection_name}"
puts "Using #{connection_name} with Identity Map #{ActiveRecord::IdentityMap.enabled? ? 'on' : 'off'}"
ActiveRecord::Base.logger = Logger.new("debug.log")
ActiveRecord::Base.configurations = connection_config
ActiveRecord::Base.establish_connection 'arunit'