Sha256: e5c562eca06f420a5123c92ddaeccf0e00712d73c7a26426aee9fbc1d26a698b

Contents?: true

Size: 1.06 KB

Versions: 15

Compression:

Stored size: 1.06 KB

Contents

require 'yaml'
require 'active_record'

# Database Defaults
host     = "localhost"
username = "thinking_sphinx"
password = nil

# Read in YAML file
if File.exist?("features/support/db/database.yml")
  config    = YAML.load open("features/support/db/database.yml")
  host      = config["host"]     || host
  username  = config["username"] || username
  password  = config["password"] || password
end

# Set up Connection
ActiveRecord::Base.establish_connection(
  :adapter  => Database,
  :database => 'thinking_sphinx',
  :username => username,
  :password => password,
  :host     => host
)

# Copied from ActiveRecord's test suite
ActiveRecord::Base.connection.class.class_eval do
  IGNORED_SQL = [
    /^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/,
    /^SELECT @@ROWCOUNT/, /^SHOW FIELDS/
  ]

  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

Version data entries

15 entries across 15 versions & 5 rubygems

Version Path
sherpa99-thinking-sphinx-1.1.4 features/support/db/active_record.rb
thinking-sphinx-1.3.4 features/support/db/active_record.rb
thinking-sphinx-1.3.3 features/support/db/active_record.rb
thinking-sphinx-099-1.3.2 features/support/db/active_record.rb
thinking-sphinx-1.3.2 features/support/db/active_record.rb
moneypools-thinking-sphinx-1.3.1 features/support/db/active_record.rb
thinking-sphinx-1.3.1 features/support/db/active_record.rb
thinking-sphinx-099-1.3.1 features/support/db/active_record.rb
thinking-sphinx-099-1.3.0 features/support/db/active_record.rb
thinking-sphinx-1.3.0 features/support/db/active_record.rb
thinking-sphinx-099-1.2.13 features/support/db/active_record.rb
thinking-sphinx-1.2.13 features/support/db/active_record.rb
moneypools-thinking-sphinx-1.2.13 features/support/db/active_record.rb
moneypools-thinking-sphinx-1.2.12 features/support/db/active_record.rb
warp-thinking-sphinx-1.2.12 features/support/db/active_record.rb