Sha256: aaee68454a3ad5a5357a211d11e4f72adc1dfb624d783f025713c8fb444989f4

Contents?: true

Size: 1.34 KB

Versions: 20

Compression:

Stored size: 1.34 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_query_record(sql, name = nil, &block)
    $queries_executed ||= []
    $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
    execute_without_query_record(sql, name, &block)
  end

  alias_method_chain :execute, :query_record
end

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

Version data entries

20 entries across 20 versions & 5 rubygems

Version Path
3mix-castronaut-0.5.0.2 vendor/activerecord/test/cases/helper.rb
masover-castronaut-0.4.4.4 vendor/activerecord/test/cases/helper.rb
masover-castronaut-0.4.4.5 vendor/activerecord/test/cases/helper.rb
masover-castronaut-0.5.0.1 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.4.1 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.4.2 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.4.3 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.4.4 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.4.5 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.4.6 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.5.0 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.5.1 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.5.2 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.5.3 vendor/activerecord/test/cases/helper.rb
relevance-castronaut-0.5.4 vendor/activerecord/test/cases/helper.rb
radiant-0.7.2 vendor/rails/activerecord/test/cases/helper.rb
activerecord-2.1.2 test/cases/helper.rb
activerecord-2.1.1 test/cases/helper.rb
radiant-0.7.0 vendor/rails/activerecord/test/cases/helper.rb
radiant-0.7.1 vendor/rails/activerecord/test/cases/helper.rb