Sha256: c3f0c8891222ec6c5f83e3958d927c9e4a08e06f2edaed2caf8af0f0bcc7c801

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

$:.unshift(File.dirname(__FILE__) + '/../../lib')

require 'config'
require 'test/unit'

require 'active_record'
require 'active_record/fixtures'
require 'active_record/test_case'
require 'connection'

# 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')

def current_adapter?(*types)
  types.any? do |type|
    ActiveRecord::ConnectionAdapters.const_defined?(type) &&
      ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters.const_get(type))
  end
end

def uses_mocha(description)
  require 'rubygems'
  require 'mocha'
  yield
rescue LoadError
  $stderr.puts "Skipping #{description} tests. `gem install mocha` and try again."
end

ActiveRecord::Base.connection.class.class_eval do
  IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/]

  def execute_with_counting(sql, name = nil, &block)
    $query_count ||= 0
    $query_count  += 1 unless IGNORED_SQL.any? { |r| sql =~ r }
    execute_without_counting(sql, name, &block)
  end

  alias_method_chain :execute, :counting
end

# Make with_scope public for tests
class << ActiveRecord::Base
  public :with_scope, :with_exclusive_scope
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
vibes-bj-1.2.2 spec/rails_root/vendor/rails/activerecord/test/cases/helper.rb
vibes-bj-1.2.1 spec/rails_root/vendor/rails/activerecord/test/cases/helper.rb
activerecord-2.1.0 test/cases/helper.rb
antfarm-0.3.0 rails/vendor/rails/activerecord/test/cases/helper.rb
antfarm-0.4.0 rails/vendor/rails/activerecord/test/cases/helper.rb