1 $
:.unshift(File
.dirname(__FILE__
) + '/../../lib')
2 $
:.unshift(File
.dirname(__FILE__
) + '/../../../activesupport/lib')
7 require 'active_record'
8 require 'active_record/fixtures'
9 require 'active_record/test_case'
12 # Show backtraces for deprecated behavior for quicker cleanup.
13 ActiveSupport
::Deprecation.debug
= true
15 # Quote "type" if it's a reserved word for the current connection.
16 QUOTED_TYPE
= ActiveRecord
::Base.connection
.quote_column_name('type')
18 def current_adapter
?(*types
)
20 ActiveRecord
::ConnectionAdapters.const_defined
?(type
) &&
21 ActiveRecord
::Base.connection
.is_a
?(ActiveRecord
::ConnectionAdapters.const_get(type
))
25 def uses_mocha(description
)
30 $stderr.puts
"Skipping #{description} tests. `gem install mocha` and try again."
33 ActiveRecord
::Base.connection
.class.class_eval
do
34 IGNORED_SQL
= [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/]
36 def execute_with_query_record(sql
, name
= nil, &block
)
37 $queries_executed ||= []
38 $queries_executed << sql
unless IGNORED_SQL
.any
? { |r
| sql
=~ r
}
39 execute_without_query_record(sql
, name
, &block
)
42 alias_method_chain
:execute, :query_record
45 # Make with_scope public for tests
46 class << ActiveRecord
::Base
47 public
:with_scope, :with_exclusive_scope
50 unless ENV['FIXTURE_DEBUG']
53 class << TestCase
#:nodoc:
54 def try_to_load_dependency_with_silence(*args
)
55 ActiveRecord
::Base.logger
.silence
{ try_to_load_dependency_without_silence(*args
)}
58 alias_method_chain
:try_to_load_dependency, :silence